Crate woodpecker [−] [src]
Woodpecker - fast and extensible logger for Rust
The main goal of woodpecker
is to be incredibly fast, extensible and easy to use.
Please check out the project homepage for more details on features, issues and limitation.
The log levels are treated in a hierarchical manner.
If there's no exact match for a requested log then the closest match is used.
That means that the log level for foo::bar::qux
is deduced from the log level
for foo::bar
unless the log level for foo::bar::qux
is explicitly set.
See documentation for the wp_get_level and log macros for more details on the hierarchy.
Installation
To start using woodpecker
just enable it in your Cargo.toml
:
[dependencies]
woodpecker = "0.4"
In the very beginning woodpecker
should be configured using wp_init macro.
By default WARN is used.
The usual logging macros as debug
, info
, etc. are available
as with generic rust logger.
Example
#[macro_use] extern crate woodpecker; use woodpecker as wp; fn main() { wp_init!(); wp_set_level!(wp::LogLevel::INFO).unwrap(); info!("{} is saying hello", "woodpecker"); debug!("I'm invisible"); }
Woodpecker supports logging in a dedicated thread.
This frees the application from the latency caused by the overhead of log string formatter and the log drain(terminal, file, network, etc.).
It's important to use sync in the end of the main
funtion
to ensure that all log records are properly flushed.
The logging thread could be activated via a configuration parameter passed
to the wp_init macro.
The WP_LOG_THREAD
environment variable may be used overrides compile-time settings.
Reexports
pub use line_range::LineRangeBound::BOF; |
pub use line_range::LineRangeBound::EOF; |
Modules
formatters |
Collection of log record formatters. |
handlers |
Collection of log handlers. |
levels |
Definition of the log levels. |
logger |
The logger core. |
record |
Definition of the log record entry. |
spec |
The logger spec might also be either env_logger spec or a JSON string which defines global and per-module log level. |
Macros
critical |
Produces log record for the |
debug |
Produces log record for the |
error |
Produces log record for the |
in_critical |
Executes the code only for the |
in_debug |
Executes the code only for the |
in_error |
Executes the code only for the |
in_info |
Executes the code only for the |
in_notice |
Executes the code only for the |
in_trace |
Executes the code only for the |
in_verbose |
Executes the code only for the |
in_warn |
Executes the code only for the |
info |
Produces log record for the |
log |
The main log entry. |
notice |
Produces log record for the |
trace |
Produces log record for the |
verbose |
Produces log for the |
warn |
Produces log record for the |
wp_get_level |
Gets the log level. |
wp_init |
Initializes the crate's kitchen. |
wp_register_handler |
Registers a log record handler. |
wp_separator |
A file-module separator. |
wp_set_formatter |
Sets a log record formatter. |
wp_set_level |
Sets the log level. |
Structs
Config |
Initial logger configuration. |
Enums
LineRangeBound |
The markers of the begging of the file and its end. |
LogLevel |
The logging levels. |
Traits
Record |
Log record that holds information where log was recorded and the message details. |
Functions
sync |
Ensures that the logging queue is completely consumed by the log thread. |