Expand description
Facilities for sending log message to syslog.
Every function exported by this module is thread-safe. Each function will silently fail until
syslog::init()
is called and returns Ok
.
This implements and sets logger up for logging facade exposed by the log
crate.
§Examples
use log::{error, warn};
use base::syslog;
if let Err(e) = syslog::init() {
println!("failed to initiailize syslog: {}", e);
return;
}
warn!("this is your {} warning", "final");
error!("something went horribly wrong: {}", "out of RAMs");
use log::{error, warn};
use base::syslog::{init_with, LogConfig, fmt};
use std::io::Write;
let mut cfg = LogConfig::default();
cfg.log_args.stderr = true;
cfg.log_args.filter = String::from("info,base=debug,base::syslog=error,serial_console=false");
init_with(cfg).unwrap();
error!("something went horribly wrong: {}", "out of RAMs");
Re-exports§
pub use env_logger;
Modules§
- Formatting for log records.
Macros§
- Logs a message at the debug level.
- Logs a message at the error level.
- Logs a message at the info level.
- The standard logging macro.
- Determines if a message logged at the specified level in that module will be logged.
- Logs a message at the trace level.
- Logs a message at the warn level.
Structs§
- The logger that is provided to the
log
crate. Wraps our State struct so that we can reconfigure logging sinks on the fly. - Metadata about a log message.
- Builder for
Metadata
. - The type returned by
from_str
when the string doesn’t match any of the log levels. - The “payload” of a log message.
- Builder for
Record
. - The type returned by
set_logger
ifset_logger
has already been called.
Enums§
- Errors returned by
syslog::init()
. - The facility of a syslog message.
- An enum representing the available verbosity levels of the logger.
- An enum representing the available verbosity level filters of the logger.
- The priority (i.e. severity) of a syslog message.
Constants§
- The statically resolved maximum log level.
Statics§
- STATE 🔒
Traits§
- A trait encapsulating the operations required of a logger.
- Syslog 🔒
Functions§
- Performs early (as in, moment of process start) logging initialization. Any logging prior to this call will be SILENTLY discarded. Calling more than once per process will panic.
- Initialize the syslog connection and internal variables.
- Initialize the syslog connection and internal variables.
- Returns a reference to the logger.
- Returns the current maximum log level.
- Retrieves the file descriptors owned by the global syslogger.
- Sets the global logger to a
Box<Log>
. - Sets the global logger to a
&'static Log
. - A thread-unsafe version of
set_logger
. - Sets the global maximum log level.
- A thread-unsafe version of
set_max_level
. - Test only function that ensures logging has been configured. Since tests share module state, we need a way to make sure it has been initialized with some configuration.