pub struct TextLayout { /* private fields */ }
Expand description
A layout that formats log record as optionally colored text.
Output format:
2024-08-11T22:44:57.172105+08:00 ERROR file: examples/file.rs:51 Hello error!
2024-08-11T22:44:57.172219+08:00 WARN file: examples/file.rs:52 Hello warn!
2024-08-11T22:44:57.172276+08:00 INFO file: examples/file.rs:53 Hello info!
2024-08-11T22:44:57.172329+08:00 DEBUG file: examples/file.rs:54 Hello debug!
2024-08-11T22:44:57.172382+08:00 TRACE file: examples/file.rs:55 Hello trace!
By default, log levels are colored. You can set the no_color
field to true
to disable
coloring.
You can also customize the color of each log level by setting the colors
field with a
LevelColor
instance.
You can customize the timezone of the timestamp by setting the tz
field with a TimeZone
instance. Otherwise, the system timezone is used.
§Examples
use logforth_layout_text::TextLayout;
let layout = TextLayout::default();
Implementations§
Source§impl TextLayout
impl TextLayout
Sourcepub fn colors(self, colors: LevelColor) -> Self
pub fn colors(self, colors: LevelColor) -> Self
Customize the color of each log level.
No effect if no_color
is set to true
.
Sourcepub fn error_color(self, color: Color) -> Self
pub fn error_color(self, color: Color) -> Self
Customize the color of the error log level. Default to red.
No effect if no_color
is set to true
.
Sourcepub fn warn_color(self, color: Color) -> Self
pub fn warn_color(self, color: Color) -> Self
Customize the color of the warn log level. Default to yellow.
No effect if no_color
is set to true
.
Sourcepub fn info_color(self, color: Color) -> Self
pub fn info_color(self, color: Color) -> Self
Customize the color of the info log level/ Default to green.
No effect if no_color
is set to true
.
Sourcepub fn debug_color(self, color: Color) -> Self
pub fn debug_color(self, color: Color) -> Self
Customize the color of the debug log level. Default to blue.
No effect if no_color
is set to true
.
Sourcepub fn trace_color(self, color: Color) -> Self
pub fn trace_color(self, color: Color) -> Self
Customize the color of the trace log level. Default to magenta.
No effect if no_color
is set to true
.
Trait Implementations§
Source§impl Clone for TextLayout
impl Clone for TextLayout
Source§fn clone(&self) -> TextLayout
fn clone(&self) -> TextLayout
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more