Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ephraimd/JLogger
An attempt at creating a pretty simple but blazing fast logger utility in Java. An attempt though
https://github.com/ephraimd/JLogger
Last synced: about 1 month ago
JSON representation
An attempt at creating a pretty simple but blazing fast logger utility in Java. An attempt though
- Host: GitHub
- URL: https://github.com/ephraimd/JLogger
- Owner: ephraimd
- License: gpl-3.0
- Created: 2020-06-21T00:58:38.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-21T02:31:23.000Z (over 4 years ago)
- Last Synced: 2024-08-02T05:13:04.785Z (4 months ago)
- Language: Java
- Homepage:
- Size: 48.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-blazingly-fast - JLogger - An attempt at creating a pretty simple but blazing fast logger utility in Java. An attempt though (Java)
README
# JLogger
An attempt at creating a pretty simple but blazing fast logger utility in Java. An attempt though### Code
```java
public class MainTest {
public static void main(String[] args){
JLogger logger = new JLogger();
logger.fine("JESUS IS LORD");
logger.setLogFilePath(Paths.get("logging.txt"));
logger.info("JESUS IS COMING SOON!!");
logger.warning("JESUS WILL COME!!");
logger.error(new IOException("NOT REPENTING AND TRUSTING GOD IS DANGEROUS!"));
logger.setLogToConsole(false);
logger.info("Lets all gather to Worship now");
logger.warning("The Time is near");
logger.setLogToConsole(true);
logger.setLogToFile(false);
logger.error(new IOException("This error is meant only for console"));
}
}
```
There are methods to check logging output type
```
logger.isLogToConsole();
logger.isLogToFile();
```
To redirect console logging to another stream
```
logger.setConsoleStream(new PrintStream(new FileOutputStream(consoleLoggingFile.toFile())));
```### Internals
JLogger's approach is to minimize the bottleneck involved in keeping logs to O(1) - bare minimum; while keeping the library as fast as possible
The measures taken to ensure this are
- Logs are kept in a ___LinkedList___ buffer and only written when the buffer reaches a predefined size. The size of this buffer can be specified with ___JLogger#setFileLogBufferSize___ method.
- JLogger attaches a Hook to the JVM's shutdown routine that empties the log buffer into the file at the end. This primarily designed for log writing accuracy.JLogger's decision to write to file or console is controlled by the ___JLogger#setLogToFile___ and ___setLogToConsole___ respectively.
By default, JLogger logs to console. When ___JLogger#setLogFilePath___ is called, ___JLogger#setLogToFile___ is called implicitly when enables file logging but does not turn off console logging.
So, control must be specified by the programmer as to how JLogger should output logs.
### Usage
Please checkout the release page for the latest artifact jar or simply clone the repo as a gradle project