Below the basics of CoralLog:. 
Level Logging
// this static import is all you need to start using CoralLog:
import static com.coralblocks.corallog.Log.*;
// if you want to log to a file, instead of to the console (stdout)
Log.setFile(true); // or -DlogFile=true (you can also use a configuration file)
 
// then, anywhere in your code you can write:
Warn.log("This is a log message!", "string=", myString, "byteBuffer=", myByteBuffer, "price=", price);
Error.log(appName, "An exception happened:", exception);
Info.log(myStringBuilder);
Info.log(myByteBuffer);
Info.log(myByteArray);
// you can also use placeholders:
Debug.log("This is a log message! user={} age={}", "foo", 21);
Event Sourcing
// pass a filename to be created in the current directory
Logger myLogger = Log.createLogger("myLogFile.log");
 
// or you can pass the directory
Logger myLogger = Log.createLogger("/var/mydir/", "myLogFile.log");
// turn off timestamps before each log line
Logger myLogger = Log.createLogger("myLogFile.log", false); // no timestamps
 
// turn off timestamps before each log line
Logger myLogger = Log.createLogger("/var/mydir/", "myLogFile.log", false); // no timestamps
// then log as usual:
myLogger.log("This is a log message!", "string=", myString, "byteBuffer=", myByteBuffer, "price=", price);
myLogger.log(appName, "An exception happened:", exception);
myLogger.log(myStringBuilder);
myLogger.log(myByteBuffer);
myLogger.log(myByteArray);
// you can also use placeholders:
myLogger.log("This is a log message! user={} age={}", "foo", 21);
Using LogConfig
LogConfig logConfig = new LogConfig(filename); // current directory // or LogConfig logConfig = new LogConfig(dir, filename); logConfig.includeLogEntrySeparator = false; // default is true logConfig.includeTopHeader = true; // default is false Logger myLogger = Log.createLogger(logConfig);
Below all the LogConfig options with their defaults:
public String dir = Log.getDir(); public boolean isSynchronized = false; public boolean isMemoryMapped = false; public int memoryMappedBufferSize = 64 * 1024 * 1024; // 64m public List<Encoder> encoders = Log.getEncoders(); public boolean isAsynchronous = true; public boolean includeTopHeader = false; public boolean includeLogEntrySeparator = true; public int outputBufferSize = 64 * 1024; // 64k (optimum) public boolean flushImmediately = false; public boolean includeTimestamp = true; public int secondsToFlush = -1; public boolean isNoSpaceBetweenObjects = false;