pub struct FormatBuilder { /* private fields */ }
Expand description
Streamer builder
Implementations§
Source§impl FormatBuilder
impl FormatBuilder
Sourcepub fn full(self) -> Self
pub fn full(self) -> Self
Output using full mode (default)
Examples found in repository?
examples/full-format.rs (line 19)
10fn main() {
11 let file = OpenOptions::new()
12 .create(true)
13 .write(true)
14 .truncate(true)
15 .open("target/log.html").unwrap();
16
17 let d1 = slog_stream::stream(
18 file,
19 slog_html::new().full().build()
20 );
21 let d2 = slog_stream::stream(
22 std::io::stderr(),
23 slog_html::new().full().build()
24 );
25
26 let root_log = slog::Logger::root(
27 slog::duplicate(d1, d2).fuse(),
28 o!("version" => env!("CARGO_PKG_VERSION"))
29 );
30
31 let server_log = root_log.new(o!("host" => "localhost", "port" => "8080"));
32 let peer1_log = server_log.new(o!("peer_addr" => "8.8.8.8", "port" => "18230"));
33 let peer2_log = server_log.new(o!("peer_addr" => "82.9.9.9", "port" => "42381"));
34
35 info!(server_log, "starting");
36 info!(server_log, "listening");
37 debug!(peer2_log, "connected");
38 debug!(peer2_log, "message received"; "length" => 2);
39 debug!(peer1_log, "connected");
40 debug!(peer2_log, "response sent"; "length" => 8);
41 debug!(peer2_log, "disconnected");
42 debug!(peer1_log, "message received"; "length" => 2);
43 debug!(peer1_log, "response sent"; "length" => 8);
44 debug!(peer1_log, "disconnected");
45 info!(server_log, "exit");
46}
Sourcepub fn compact(self) -> Self
pub fn compact(self) -> Self
Output using compact mode
Examples found in repository?
examples/compact-format.rs (line 19)
10fn main() {
11 let file = OpenOptions::new()
12 .create(true)
13 .write(true)
14 .truncate(true)
15 .open("target/log.html").unwrap();
16
17 let d1 = slog_stream::stream(
18 file,
19 slog_html::new().compact().build()
20 );
21 let d2 = slog_stream::stream(
22 std::io::stderr(),
23 slog_html::new().compact().build()
24 );
25
26 let root_log = slog::Logger::root(
27 slog::duplicate(d1, d2).fuse(),
28 o!("version" => env!("CARGO_PKG_VERSION"))
29 );
30
31 let server_log = root_log.new(o!("host" => "localhost", "port" => "8080"));
32 let peer1_log = server_log.new(o!("peer_addr" => "8.8.8.8", "port" => "18230"));
33 let peer2_log = server_log.new(o!("peer_addr" => "82.9.9.9", "port" => "42381"));
34
35 info!(server_log, "starting");
36 info!(server_log, "listening");
37 debug!(peer2_log, "connected");
38 debug!(peer2_log, "message received"; "length" => 2);
39 debug!(peer1_log, "connected");
40 debug!(peer2_log, "response sent"; "length" => 8);
41 debug!(peer2_log, "disconnected");
42 debug!(peer1_log, "message received"; "length" => 2);
43 debug!(peer1_log, "response sent"; "length" => 8);
44 debug!(peer1_log, "disconnected");
45 info!(server_log, "exit");
46}
Sourcepub fn color_palette(self, color_palette: ColorPalette) -> Self
pub fn color_palette(self, color_palette: ColorPalette) -> Self
Use custom color palette
Sourcepub fn level_style(self, style: Style) -> Self
pub fn level_style(self, style: Style) -> Self
Use custom style for the log level
Sourcepub fn timestamp_style(self, style: Style) -> Self
pub fn timestamp_style(self, style: Style) -> Self
Use custom style for the timestamp
Sourcepub fn message_style(self, style: Style) -> Self
pub fn message_style(self, style: Style) -> Self
Use custom style for the message
Sourcepub fn value_style(self, style: Style) -> Self
pub fn value_style(self, style: Style) -> Self
Use custom style for values
Sourcepub fn separator_style(self, style: Style) -> Self
pub fn separator_style(self, style: Style) -> Self
Use custom style for separators
Sourcepub fn use_utc_timestamp(self) -> Self
pub fn use_utc_timestamp(self) -> Self
Use the UTC time zone for the timestamp
Sourcepub fn use_local_timestamp(self) -> Self
pub fn use_local_timestamp(self) -> Self
Use the local time zone for the timestamp (default)
Sourcepub fn use_custom_timestamp<F>(self, f: F) -> Self
pub fn use_custom_timestamp<F>(self, f: F) -> Self
Provide a custom function to generate the timestamp
Sourcepub fn build(self) -> Format<HtmlDecorator>
pub fn build(self) -> Format<HtmlDecorator>
Build Html formatter
Examples found in repository?
examples/full-format.rs (line 19)
10fn main() {
11 let file = OpenOptions::new()
12 .create(true)
13 .write(true)
14 .truncate(true)
15 .open("target/log.html").unwrap();
16
17 let d1 = slog_stream::stream(
18 file,
19 slog_html::new().full().build()
20 );
21 let d2 = slog_stream::stream(
22 std::io::stderr(),
23 slog_html::new().full().build()
24 );
25
26 let root_log = slog::Logger::root(
27 slog::duplicate(d1, d2).fuse(),
28 o!("version" => env!("CARGO_PKG_VERSION"))
29 );
30
31 let server_log = root_log.new(o!("host" => "localhost", "port" => "8080"));
32 let peer1_log = server_log.new(o!("peer_addr" => "8.8.8.8", "port" => "18230"));
33 let peer2_log = server_log.new(o!("peer_addr" => "82.9.9.9", "port" => "42381"));
34
35 info!(server_log, "starting");
36 info!(server_log, "listening");
37 debug!(peer2_log, "connected");
38 debug!(peer2_log, "message received"; "length" => 2);
39 debug!(peer1_log, "connected");
40 debug!(peer2_log, "response sent"; "length" => 8);
41 debug!(peer2_log, "disconnected");
42 debug!(peer1_log, "message received"; "length" => 2);
43 debug!(peer1_log, "response sent"; "length" => 8);
44 debug!(peer1_log, "disconnected");
45 info!(server_log, "exit");
46}
More examples
examples/compact-format.rs (line 19)
10fn main() {
11 let file = OpenOptions::new()
12 .create(true)
13 .write(true)
14 .truncate(true)
15 .open("target/log.html").unwrap();
16
17 let d1 = slog_stream::stream(
18 file,
19 slog_html::new().compact().build()
20 );
21 let d2 = slog_stream::stream(
22 std::io::stderr(),
23 slog_html::new().compact().build()
24 );
25
26 let root_log = slog::Logger::root(
27 slog::duplicate(d1, d2).fuse(),
28 o!("version" => env!("CARGO_PKG_VERSION"))
29 );
30
31 let server_log = root_log.new(o!("host" => "localhost", "port" => "8080"));
32 let peer1_log = server_log.new(o!("peer_addr" => "8.8.8.8", "port" => "18230"));
33 let peer2_log = server_log.new(o!("peer_addr" => "82.9.9.9", "port" => "42381"));
34
35 info!(server_log, "starting");
36 info!(server_log, "listening");
37 debug!(peer2_log, "connected");
38 debug!(peer2_log, "message received"; "length" => 2);
39 debug!(peer1_log, "connected");
40 debug!(peer2_log, "response sent"; "length" => 8);
41 debug!(peer2_log, "disconnected");
42 debug!(peer1_log, "message received"; "length" => 2);
43 debug!(peer1_log, "response sent"; "length" => 8);
44 debug!(peer1_log, "disconnected");
45 info!(server_log, "exit");
46}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FormatBuilder
impl !RefUnwindSafe for FormatBuilder
impl Send for FormatBuilder
impl Sync for FormatBuilder
impl Unpin for FormatBuilder
impl !UnwindSafe for FormatBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more