Struct flexi_logger::ReconfigurationHandle
source · pub struct ReconfigurationHandle { /* private fields */ }
Expand description
Allows reconfiguring the logger while it is in use
(see Logger::start_reconfigurable()
).
Example
Use the reconfigurability feature and build the log spec programmatically.
extern crate log;
extern crate flexi_logger;
use flexi_logger::{Logger, LogSpecBuilder};
use log::LevelFilter;
fn main() {
// Build the initial log specification
let mut builder = LogSpecBuilder::new(); // default is LevelFilter::Off
builder.default(LevelFilter::Info);
builder.module("karl", LevelFilter::Debug);
// Initialize Logger, keep builder alive
let mut logger_reconf_handle = Logger::with(builder.build())
// your logger configuration goes here, as usual
.start_reconfigurable()
.unwrap_or_else(|e| panic!("Logger initialization failed with {}", e));
// ...
// Modify builder and update the logger
builder.default(LevelFilter::Error);
builder.remove("karl");
builder.module("emma", LevelFilter::Trace);
logger_reconf_handle.set_new_spec(builder.build());
// ...
}
Implementations§
source§impl ReconfigurationHandle
impl ReconfigurationHandle
sourcepub fn set_new_spec(&mut self, new_spec: LogSpecification)
pub fn set_new_spec(&mut self, new_spec: LogSpecification)
Allows specifying a new LogSpecification for the current logger.
sourcepub fn parse_new_spec(&mut self, spec: &str)
pub fn parse_new_spec(&mut self, spec: &str)
Allows specifying a new LogSpecification for the current logger.