mirror of
https://github.com/rust-lang/log.git
synced 2025-09-30 06:20:38 +00:00
commit
044e328698
35
src/lib.rs
35
src/lib.rs
@ -94,8 +94,9 @@
|
|||||||
//!
|
//!
|
||||||
//! # Logger implementations
|
//! # Logger implementations
|
||||||
//!
|
//!
|
||||||
//! Loggers implement the `Log` trait. Here's a very basic example that simply
|
//! Loggers implement the [`Log`] trait. Here's a very basic example that simply
|
||||||
//! logs all messages at the `Error`, `Warn` or `Info` levels to stdout:
|
//! logs all messages at the [`Error`][level_link], [`Warn`][level_link] or
|
||||||
|
//! [`Info`][level_link] levels to stdout:
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! extern crate log;
|
//! extern crate log;
|
||||||
@ -119,15 +120,16 @@
|
|||||||
//! # fn main() {}
|
//! # fn main() {}
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! Loggers are installed by calling the `set_logger` function. It takes a
|
//! Loggers are installed by calling the [`set_logger`] function. It takes a
|
||||||
//! closure which is provided a `MaxLogLevel` token and returns a `Log` trait
|
//! closure which is provided a [`MaxLogLevelFilter`] token and returns a
|
||||||
//! object. The `MaxLogLevel` token controls the global maximum log level. The
|
//! [`Log`] trait object. The [`MaxLogLevelFilter`] token controls the global
|
||||||
//! logging facade uses this as an optimization to improve performance of log
|
//! maximum log level. The logging facade uses this as an optimization to
|
||||||
//! messages at levels that are disabled. In the case of our example logger,
|
//! improve performance of log messages at levels that are disabled. In the
|
||||||
//! we'll want to set the maximum log level to `Info`, since we ignore any
|
//! case of our example logger, we'll want to set the maximum log level to
|
||||||
//! `Debug` or `Trace` level log messages. A logging framework should provide a
|
//! [`Info`][level_link], since we ignore any [`Debug`][level_link] or
|
||||||
//! function that wraps a call to `set_logger`, handling initialization of the
|
//! [`Trace`][level_link] level log messages. A logging framework should
|
||||||
//! logger:
|
//! provide a function that wraps a call to [`set_logger`], handling
|
||||||
|
//! initialization of the logger:
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! # extern crate log;
|
//! # extern crate log;
|
||||||
@ -152,8 +154,8 @@
|
|||||||
//! To use the `log` crate without depending on `libstd`, you need to specify
|
//! To use the `log` crate without depending on `libstd`, you need to specify
|
||||||
//! `default-features = false` when specifying the dependency in `Cargo.toml`.
|
//! `default-features = false` when specifying the dependency in `Cargo.toml`.
|
||||||
//! This makes no difference to libraries using `log` since the logging API
|
//! This makes no difference to libraries using `log` since the logging API
|
||||||
//! remains the same. However executables will need to use the `set_logger_raw`
|
//! remains the same. However executables will need to use the [`set_logger_raw`]
|
||||||
//! function to initialize a logger and the `shutdown_logger_raw` function to
|
//! function to initialize a logger and the [`shutdown_logger_raw`] function to
|
||||||
//! shut down the global logger before exiting:
|
//! shut down the global logger before exiting:
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
@ -185,6 +187,13 @@
|
|||||||
//! })
|
//! })
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
//!
|
||||||
|
//! [`Log`]: trait.Log.html
|
||||||
|
//! [level_link]: enum.LogLevel.html
|
||||||
|
//! [`set_logger`]: fn.set_logger.html
|
||||||
|
//! [`MaxLogLevelFilter`]: struct.MaxLogLevelFilter.html
|
||||||
|
//! [`set_logger_raw`]: fn.set_logger_raw.html
|
||||||
|
//! [`shutdown_logger_raw`]: fn.shutdown_logger_raw.html
|
||||||
|
|
||||||
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||||
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
|
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user