Lines Matching defs:log
13 //! The `log` crate provides a single logging API that abstracts over the
19 //! implementation that ignores all log messages. The overhead in this case
22 //! A log request consists of a _target_, a _level_, and a _body_. A target is a
23 //! string which defaults to the module path of the location of the log request,
29 //! The basic use of the log crate is through the five logging macros: [`error!`],
31 //! where `error!` represents the highest-priority log messages
32 //! and `trace!` the lowest. The log messages are filtered by configuring
33 //! the log level to exclude messages with a lower priority.
46 //! Libraries should link only to the `log` crate, and use the provided
47 //! macros to log whatever information will be useful to downstream consumers.
55 //! use log::{info, warn};
80 //! function to do this. Any log messages generated before
83 //! The executable itself may use the `log` crate to log as well.
92 //! with your log records. If we take the example from before, we can include
102 //! use log::{info, warn, as_serde, as_error};
127 //! In order to produce log output executables have to use
152 //! * You may need to construct an FFI-safe wrapper over `log` to initialize in your libraries
161 //! use log::{Record, Level, Metadata};
165 //! impl log::Log for SimpleLogger {
170 //! fn log(&self, record: &Record) {
183 //! log level also needs to be adjusted via the [`set_max_level`] function. The
184 //! logging facade uses this as an optimization to improve performance of log
186 //! defaults to [`Off`][filter_link], so no log messages will ever be captured!
187 //! In the case of our example logger, we'll want to set the maximum log level
189 //! [`Trace`][level_link] level log messages. A logging implementation should
194 //! # use log::{Level, Metadata};
196 //! # impl log::Log for SimpleLogger {
198 //! # fn log(&self, _: &log::Record) {}
202 //! use log::{SetLoggerError, LevelFilter};
207 //! log::set_logger(&LOGGER)
208 //! .map(|()| log::set_max_level(LevelFilter::Info))
213 //! to adjust the maximum log level as well.
224 //! # use log::{Level, LevelFilter, Log, SetLoggerError, Metadata};
226 //! # impl log::Log for SimpleLogger {
228 //! # fn log(&self, _: &log::Record) {}
234 //! log::set_boxed_logger(Box::new(SimpleLogger))
235 //! .map(|()| log::set_max_level(LevelFilter::Info))
269 //! log = { version = "0.4", features = ["max_level_debug", "release_max_level_warn"] }
282 //! log = { version = "0.4", features = ["std", "serde"] }
287 //! The 0.3 and 0.4 versions of the `log` crate are almost entirely compatible. Log messages
288 //! made using `log` 0.3 will forward transparently to a logger implementation using `log` 0.4. Log
289 //! messages made using `log` 0.4 will forward to a logger implementation using `log` 0.3, but the
317 html_root_url = "https://docs.rs/log/0.4.17"
416 "attempted to convert a string that doesn't match an existing log level";
422 /// [`log!`](macro.log.html), and comparing a `Level` directly to a
615 /// The order of iteration is from more severe to less severe log messages.
620 /// use log::Level;
635 /// to get and set the maximum log level with [`max_level()`] and [`set_max_level`].
643 /// A level lower than all log levels.
645 /// Corresponds to the `Error` log level.
647 /// Corresponds to the `Warn` log level.
649 /// Corresponds to the `Info` log level.
651 /// Corresponds to the `Debug` log level.
653 /// Corresponds to the `Trace` log level.
801 /// use log::LevelFilter;
829 /// The "payload" of a log message.
833 /// `Record` structures are passed as parameters to the [`log`][method.log]
835 /// structures in order to display log messages. `Record`s are automatically
836 /// created by the [`log!`] macro and so are not seen by log users.
850 /// impl log::Log for SimpleLogger {
851 /// fn enabled(&self, metadata: &log::Metadata) -> bool {
855 /// fn log(&self, record: &log::Record) {
869 /// [method.log]: trait.Log.html#tymethod.log
871 /// [`log!`]: macro.log.html
915 /// Metadata about the log directive.
998 /// Typically should only be used by log library creators or for testing and "shim loggers".
1005 /// use log::{Level, Record};
1020 /// use log::{Record, Level, MetadataBuilder};
1146 /// Metadata about a log message.
1156 /// `Record`s use `Metadata` to determine the log message's severity
1160 /// constructing expensive log messages.
1165 /// use log::{Record, Level, Metadata};
1169 /// impl log::Log for MyLogger {
1174 /// fn log(&self, record: &Record) {
1212 /// Typically should only be used by log library creators or for testing and "shim loggers".
1220 /// use log::{Level, MetadataBuilder};
1271 /// Determines if a log message with the specified metadata would be
1275 /// expensive computation of log message arguments if the message would be
1280 /// This method isn't called automatically by the `log!` macros.
1282 /// `log` method implementation to guarantee that filtering is applied.
1290 /// Implementations of `log` should perform all necessary filtering
1292 fn log(&self, record: &Record);
1306 fn log(&self, _: &Record) {}
1318 fn log(&self, record: &Record) {
1319 (**self).log(record)
1335 fn log(&self, record: &Record) {
1336 self.as_ref().log(record)
1352 fn log(&self, record: &Record) {
1353 self.as_ref().log(record)
1360 /// Sets the global maximum log level.
1370 /// Returns the current maximum log level.
1372 /// The [`log!`], [`error!`], [`warn!`], [`info!`], [`debug!`], and [`trace!`] macros check
1374 /// log level is set by the [`set_max_level`] function.
1376 /// [`log!`]: macro.log.html
1414 /// This function may only be called once in the lifetime of a program. Any log
1435 /// use log::{error, info, warn, Record, Level, Metadata, LevelFilter};
1441 /// impl log::Log for MyLogger {
1446 /// fn log(&self, record: &Record) {
1455 /// log::set_logger(&MY_LOGGER).unwrap();
1456 /// log::set_max_level(LevelFilter::Info);
1458 /// info!("hello log");
1554 /// The type returned by [`from_str`] when the string doesn't match any of the log levels.
1598 logger().log(
1619 logger().log(
1644 /// The statically resolved maximum log level.
1648 /// This value is checked by the log macros, but not by the `Log`ger returned by