-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,24 @@ | ||
# fast-log | ||
High-performance logger with lock-free ring buffer | ||
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: | ||
|
||
```rust | ||
let o = LoggerFileOptions { | ||
path: "log.txt", | ||
append_mode: false, // should the logger just append to what's already there or overwrite? | ||
}; | ||
|
||
// The size is bounded, issuing a new log when the ringbuffer is full will block. | ||
let logger = Logger::new(1024 * 8, Some(o)); | ||
|
||
// Log to stdout | ||
logger.log(|| format!("To stdout: {}", 42)); | ||
|
||
// Log to the file, format_log! will prepend the file and LOC location to the log. | ||
logger.log_f(|| format_log!("To log.txt {}", 5)); // path/to/file:LINE: To log.txt 5 | ||
|
||
// Blocks until all logs are handled. | ||
logger.shutdown(); | ||
``` |