Struct flexi_logger::LoggerHandle [−][src]
Allows reconfiguring the logger programmatically.
Example
Obtain the LoggerHandle
(using .start()
):
let mut logger = Logger::with_str("info") // ... your logger configuration goes here, as usual .start() .unwrap_or_else(|e| panic!("Logger initialization failed with {}", e)); // ...
You can permanently exchange the log specification programmatically, anywhere in your code:
// ... logger.parse_new_spec("warn"); // ...
However, when debugging, you often want to modify the log spec only temporarily, for
one or few method calls only; this is easier done with the following method, because
it allows switching back to the previous spec:
logger.parse_and_push_temp_spec("trace"); // ... // critical calls // ... logger.pop_temp_spec(); // Continue with the log spec you had before. // ...
Implementations
impl LoggerHandle
[src]
pub fn set_new_spec(&mut self, new_spec: LogSpecification)
[src]
Replaces the active LogSpecification
.
pub fn parse_new_spec(&mut self, spec: &str)
[src]
Tries to replace the active LogSpecification
with the result from parsing the given String.
pub fn push_temp_spec(&mut self, new_spec: LogSpecification)
[src]
Replaces the active LogSpecification
and pushes the previous one to a Stack.
pub fn parse_and_push_temp_spec(&mut self, new_spec: &str)
[src]
Tries to replace the active LogSpecification
with the result from parsing the given String
and pushes the previous one to a Stack.
pub fn pop_temp_spec(&mut self)
[src]
Reverts to the previous LogSpecification
, if any.
pub fn flush(&self)
[src]
Flush all writers.
pub fn shutdown(&self)
[src]
Shutdown all participating writers.
This method is supposed to be called at the very end of your program, if
- you use buffering (to ensure that all buffered log lines are flushed before the program terminates)
- you use your own writer(s) (in case they need to cleanup resources)
- or if you want to securely shutdown the cleanup-thread of the
FileLogWriter
(if you use aCleanup
strategy with compressing, and your process terminates without correctly shutting down the cleanup-thread, then you might stop the cleanup-thread while it is compressing a log file, which can leave unexpected files in the filesystem)
See also LogWriter::shutdown
.
Trait Implementations
impl Clone for LoggerHandle
[src]
fn clone(&self) -> LoggerHandle
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl !RefUnwindSafe for LoggerHandle
impl Send for LoggerHandle
impl Sync for LoggerHandle
impl Unpin for LoggerHandle
impl !UnwindSafe for LoggerHandle
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,