pub struct JloggerBuilder<'a> { /* private fields */ }
Implementations§
Source§impl<'a> JloggerBuilder<'a>
impl<'a> JloggerBuilder<'a>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new JloggerBuilder which is used to build a Jlogger.
§Examples
use jlogger_tracing::{JloggerBuilder, LogTimeFormat, LevelFilter};
JloggerBuilder::new()
.max_level(LevelFilter::DEBUG)
.log_console(true)
.log_time(LogTimeFormat::TimeStamp)
.log_file(Some(("/tmp/my_log.log", false)))
.build();
Sourcepub fn max_level(self, max_level: LevelFilter) -> Self
pub fn max_level(self, max_level: LevelFilter) -> Self
Set the max level to be outputted. Log messages with a level below it will not be outputted. At runtime, the log level can be filtered though “JLOGGER_LEVEL” environment variable.
Sourcepub fn log_console(self, log_console: bool) -> Self
pub fn log_console(self, log_console: bool) -> Self
If enabled, log message will be printed to the console. Default is true.
Sourcepub fn log_file(self, log_file: Option<(&'a str, bool)>) -> Self
pub fn log_file(self, log_file: Option<(&'a str, bool)>) -> Self
Log file name. If specified, log message will be outputted to it. A tuple (log_file: &str, append: bool) is used to specify the log file. if “append” is true and the log file already exists, the log message will be appended to the log file. Otherwise a new log file will be created.
Sourcepub fn log_runtime(self, log_runtime: bool) -> Self
pub fn log_runtime(self, log_runtime: bool) -> Self
Add runtime information to log message. If the current thread name is set, it will be used as runtime information, otherwise process name is used
DEBUG thread1 : logging from thread thread1.
DEBUG jlogger-cac0970c6f073082 : logging from a thread whose name is not set.
Sourcepub fn log_time(self, time_format: LogTimeFormat) -> Self
pub fn log_time(self, time_format: LogTimeFormat) -> Self
Time stamp string format, only take effect when time stamp is enable in the log.
- TimeStamp
Timestamp (from system boot) will be outputted in the log message.
9080.163365118 DEBUG test_debug_macro : src/lib.rs-364 : this is debug
9083.164066687 INFO test_debug_macro : this is info
- TimeLocal
Date and time are printed in the log message.
2022-05-17 13:00:03 DEBUG : src/lib.rs-363 : this is debug
2022-05-17 13:00:06 INFO : this is info
- TimeNone No timestamp included in the log message.
Sourcepub fn tracing_span_event(self, span: FmtSpan) -> Self
pub fn tracing_span_event(self, span: FmtSpan) -> Self
Enable tracing span event. See tracing_subscriber::fmt::format::FmtSpan for detail This only take affect when tracing::Span is used.