Struct jlogger::JloggerBuilder

source ·
pub struct JloggerBuilder { /* private fields */ }

Implementations§

Create a new JloggerBuilder which is used to build a Jlogger.

Examples
    use log::LevelFilter;
    use jlogger::{JloggerBuilder, LogTimeFormat};

    JloggerBuilder::new()
       .max_level(LevelFilter::Debug)
       .log_console(true)
       .log_time(LogTimeFormat::TimeStamp)
       .log_file(Some("/tmp/my_log.log"), false)
       .build();

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.

If enabled, log message will be printed to the console. Default is true.

Log file name. If specified, log message will be outputted to it. If append is true and the log file exists, new messages well be appended to the end of the file. Otherwise, a new log file will be created.

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.

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.

Build a Jlogger.

Trait Implementations§

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.