pub struct Builder { /* private fields */ }
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn new() -> Builder
pub fn new() -> Builder
Create a ftlog builder with default settings:
- global log level: INFO
- root log level: INFO
- default formatter:
FtLogFormatter
- output to stderr
- bounded channel between worker thread and log thread, with a size limit of 100_000
- discard excessive log messages
- log with timestamp of local timezone
Sourcepub fn format<F: FtLogFormat + 'static>(self, format: F) -> Builder
pub fn format<F: FtLogFormat + 'static>(self, format: F) -> Builder
Set custom formatter
Sourcepub fn bounded(self, size: usize, block_when_full: bool) -> Builder
pub fn bounded(self, size: usize, block_when_full: bool) -> Builder
bound channel between worker thread and log thread
When block_when_full
is true, it will block current thread where
log macro (e.g. log::info
) is called until log thread is able to handle new message.
Otherwises, excessive log messages will be discarded.
By default, excessive log messages is discarded silently. To show how many log
messages have been dropped, see Builder::print_omitted_count()
.
Sourcepub fn print_omitted_count(self, print: bool) -> Builder
pub fn print_omitted_count(self, print: bool) -> Builder
whether to print the number of omitted logs if channel to log thread is bounded, and set to discard excessive log messages
Sourcepub fn unbounded(self) -> Builder
pub fn unbounded(self) -> Builder
set channel size to unbound
ATTENTION: too much log message will lead to huge memory consumption, as log messages are queued to be handled by log thread. When log message exceed the current channel size, it will double the size by default, Since channel expansion asks for memory allocation, log calls can be slow down.
pub fn filter<A: Into<Option<&'static str>>, L: Into<Option<LevelFilter>>>( self, module_path: &'static str, appender: A, level: L, ) -> Builder
Sourcepub fn max_log_level(self, level: LevelFilter) -> Builder
pub fn max_log_level(self, level: LevelFilter) -> Builder
Set max log level
Logs with level more verbose than this will not be sent to log thread.
Sourcepub fn root_log_level(self, level: LevelFilter) -> Builder
pub fn root_log_level(self, level: LevelFilter) -> Builder
Set max log level
Logs with level more verbose than this will not be sent to log thread.