ring-log
High-performance logger with lock-free ring buffer, use this library when you want to log in the hotpath and performance is critical.
Example
Submitting a log to either stdout or a file is very simple, you just give a closure which evaluates to a string. This is extremely fast, usually less than 100 nanos. A simple example:
let o = LoggerFileOptions ;
// The size is bounded, issuing a new log when the ringbuffer is full will block.
// When passing a LoggerFileOptions, .with_log_type(LogTo::File) is set implicitly.
let logger = builder.with_time;
// Log to file
logger.info;
logger.info;
logger.debug;
// Log to stdout, without date/time
let logger = logger.with_log_type.with_time;
// Will now log to stdout
logger.info;
logger.info;
logger.debug;
// Set it back to file
let logger = logger.with_log_type;
// Blocks until all logs are handled. Natural race condition if this is not called.
logger.shutdown;
let logger = Logger::builder(1024, None).with_time(true);
logger.info(String::new);
logger.info(|| String::from("hello"));
logger.debug(|| "foo");
let logger = logger.with_time(false);
logger.error(|| "bar");
logger.warning(|| "world");
logger.shutdown();