Expand description
Macros for multi-level formatted logging used by ArceOS.
The log macros, in descending order of level, are: error!
, warn!
,
info!
, debug!
, and trace!
.
If it is used in no_std
environment, the users need to implement the
LogIf
to provide external functions such as console output.
To use in the std
environment, please enable the std
feature:
[dependencies]
axlog = { version = "0.1", features = ["std"] }
Cargo features:
std
: Use in thestd
environment. If it is enabled, you can use console output without implementing theLogIf
trait. This is disabled by default.log-level-off
: Disable all logging. If it is enabled, all log macros (e.g.info!
) will be optimized out to a no-op in compilation time.log-level-error
: Set the maximum log level toerror
. Any macro with a level lower thanerror!
(e.g,warn!
,info!
, …) will be optimized out to a no-op.log-level-warn
,log-level-info
,log-level-debug
,log-level-trace
: Similar tolog-level-error
.
Examples
use axlog::{debug, error, info, trace, warn};
// Initialize the logger.
axlog::init();
// Set the maximum log level to `info`.
axlog::set_max_level("info");
// The following logs will be printed.
error!("error");
warn!("warn");
info!("info");
// The following logs will not be printed.
debug!("debug");
trace!("trace");
Macros
- Prints to the console.
- Prints to the console, with a newline.
- Logs a message at the debug level.
- Logs a message at the error level.
- Logs a message at the info level.
- Logs a message at the trace level.
- Logs a message at the warn level.
Traits
- Extern interfaces that must be implemented in other crates.
Functions
- Initializes the logger.
- Prints the formatted string to the console.
- Set the maximum log level.