Expand description
Diagnostics logging (TDLogLevel, custom loggers).
SDK diagnostics logging.
Logging is disabled by default (TDLogLevel::Off). Raise the level with
set_log_level, or route diagnostics into your own logging stack by
installing a TDLogger implementation with set_custom_logger:
use std::sync::{Arc, Mutex};
use thinkingdata_core::log::{set_custom_logger, set_log_level, TDLogger, TDLogLevel};
struct Collect(Mutex<Vec<String>>);
impl TDLogger for Collect {
fn print(&self, message: &str) {
self.0.lock().unwrap().push(message.to_string());
}
}
set_custom_logger(Arc::new(Collect(Mutex::new(Vec::new()))));
set_log_level(TDLogLevel::Info);
assert_eq!(thinkingdata_core::log::get_log_level(), TDLogLevel::Info);
set_log_level(TDLogLevel::Off);Enums§
- TDLog
Level - The log output level, ordered from quietest to most verbose.
Constants§
- SDK_
LOG_ PREFIX - Prefix prepended to every diagnostic message.
Traits§
- TDLogger
- A destination for SDK diagnostic messages.
Functions§
- clear_
custom_ logger - Remove a previously installed custom logger.
- get_
log_ level - Get the current log output level.
- set_
custom_ logger - Install a custom logger that receives every formatted diagnostic message.
- set_
log_ level - Set the log output level.