[−][src]Crate logosaurus
The logosaurus crate provides a logging implementation that works with the log crate. The
crate and the logger are modeled after the Go standard library's log package.
The primary type is Logger, which represents a logging object.
Use init to globally initialize a logger with the log crate.
Every log message is output on a separate line: if the message being printed does not end in a newline, the logger will add one.
Sample default log output:
WARN 2020/10/02 21:27:03 hello, world
Examples
Using the default logger
use log::{debug}; use logosaurus::{Logger}; fn main() { logosaurus::init(Logger::default()).unwrap(); debug!("hello, world"); // DEBUG 2020/10/02 21:27:03 hello, world }
Using a custom logger
use log::{self, debug}; use logosaurus::{Logger, L_STD, L_SHORT_FILE, L_MICROSECONDS}; use std::io; fn main() { let logger = Logger::builder() .set_level(log::LevelFilter::Debug) .set_out(Box::new(io::stderr())) .set_flags(L_STD | L_SHORT_FILE | L_MICROSECONDS) .set_prefix("myprogram: ") .build(); logosaurus::init(logger).unwrap(); debug!("hello, world"); // myprogram: DEBUG 2020/10/02 21:27:03.123123 main.rs:12: hello, world }
Modules
| test_util |
Structs
| Logger | Represents a logging object that writes to a specified output. It can be used simultaneously from multiple threads; it guarantees to serialize writes. |
| LoggerBuilder | Builder for |
Constants
| L_DATE | Date in local time zone: 2009/01/23. |
| L_LEVEL | Log level printed in capitalized form: INFO, TRACE, etc. Padded to width 5. |
| L_LONG_FILE | Module, file name, and line number: |
| L_MICROSECONDS | Microsecond resolution: 17:05:23.023123; assumes |
| L_MSG_PREFIX | Move the "prefix" from the beginning of the header to the end of the header, just before the message. |
| L_NONE | No header. |
| L_SHORT_FILE | Final file name element and line number: |
| L_STD | Initial values for the default logger constructed with |
| L_TIME | Time in local time zone: 17:05:23. |
| L_UTC | If |
Functions
| init | Initialize the logger to use with the |
Type Definitions
| Flag | Formatting flags for the header in log output.
See the |