pub struct SystemdLayer { /* private fields */ }
Expand description
A configurable tracing-subscriber layer compatible with journald.
The layer used to format and log events. Can be configured to log to stdout, or directly to journald using the sd-journal
feature.
let systemd_layer = SystemdLayer::new()
.with_target(true)
.use_level_prefix(false)
.use_color(true);
Implementations§
Source§impl SystemdLayer
impl SystemdLayer
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new SystemdLayer
with default configuration.
Examples found in repository?
6fn main() {
7 tracing_subscriber::registry()
8 .with(
9 SystemdLayer::new()
10 .with_target(true)
11 .use_level_prefix(false)
12 .use_color(true)
13 .with_thread_ids(true),
14 )
15 .init();
16
17 root_log_fn(true);
18}
Sourcepub fn with_thread_ids(self, log_thread_id: bool) -> Self
pub fn with_thread_ids(self, log_thread_id: bool) -> Self
Sets whether or not to include thread IDs (default: false)
Examples found in repository?
6fn main() {
7 tracing_subscriber::registry()
8 .with(
9 SystemdLayer::new()
10 .with_target(true)
11 .use_level_prefix(false)
12 .use_color(true)
13 .with_thread_ids(true),
14 )
15 .init();
16
17 root_log_fn(true);
18}
Sourcepub fn separate_spans_with(self, span_separator: &'static str) -> Self
pub fn separate_spans_with(self, span_separator: &'static str) -> Self
Sets the span separator (default: “::”)
Sourcepub fn separate_message_with(self, message_separator: &'static str) -> Self
pub fn separate_message_with(self, message_separator: &'static str) -> Self
Sets the message separator (default: “: “)
Sourcepub fn with_target(self, display_target: bool) -> Self
pub fn with_target(self, display_target: bool) -> Self
Sets whether or not to include the target (default: false)
Examples found in repository?
6fn main() {
7 tracing_subscriber::registry()
8 .with(
9 SystemdLayer::new()
10 .with_target(true)
11 .use_level_prefix(false)
12 .use_color(true)
13 .with_thread_ids(true),
14 )
15 .init();
16
17 root_log_fn(true);
18}
Sourcepub fn function_bracket_left(self, function_bracket_left: &'static str) -> Self
pub fn function_bracket_left(self, function_bracket_left: &'static str) -> Self
Sets the left bracket for function names (default: “(”)
Sourcepub fn function_bracket_right(
self,
function_bracket_right: &'static str,
) -> Self
pub fn function_bracket_right( self, function_bracket_right: &'static str, ) -> Self
Sets the right bracket for function names (default: “)”)
Sourcepub fn arguments_equality(self, arguments_equality: &'static str) -> Self
pub fn arguments_equality(self, arguments_equality: &'static str) -> Self
Sets the equality sign for arguments (default: “: “)
Sourcepub fn arguments_separator(self, arguments_separator: &'static str) -> Self
pub fn arguments_separator(self, arguments_separator: &'static str) -> Self
Sets the separator for arguments (default: “, “)
Sourcepub fn level_separator(self, level_separator: &'static str) -> Self
pub fn level_separator(self, level_separator: &'static str) -> Self
Sets the separator for levels (default: “ “)
Sourcepub fn thread_id_prefix(self, thread_id_prefix: &'static str) -> Self
pub fn thread_id_prefix(self, thread_id_prefix: &'static str) -> Self
Sets the prefix for thread IDs (default: “[”)
Sourcepub fn thread_id_suffix(self, thread_id_suffix: &'static str) -> Self
pub fn thread_id_suffix(self, thread_id_suffix: &'static str) -> Self
Sets the suffix for thread IDs (default: “] “)
Sourcepub fn use_level_prefix(self, use_level_prefix: bool) -> Self
pub fn use_level_prefix(self, use_level_prefix: bool) -> Self
Sets whether or not to use level prefixes (default: true)
Examples found in repository?
6fn main() {
7 tracing_subscriber::registry()
8 .with(
9 SystemdLayer::new()
10 .with_target(true)
11 .use_level_prefix(false)
12 .use_color(true)
13 .with_thread_ids(true),
14 )
15 .init();
16
17 root_log_fn(true);
18}
Sourcepub fn use_color(self, use_color: bool) -> Self
pub fn use_color(self, use_color: bool) -> Self
Sets whether or not to use color
Examples found in repository?
6fn main() {
7 tracing_subscriber::registry()
8 .with(
9 SystemdLayer::new()
10 .with_target(true)
11 .use_level_prefix(false)
12 .use_color(true)
13 .with_thread_ids(true),
14 )
15 .init();
16
17 root_log_fn(true);
18}
Trait Implementations§
Source§impl<S> Layer<S> for SystemdLayerwhere
S: Subscriber + for<'a> LookupSpan<'a>,
impl<S> Layer<S> for SystemdLayerwhere
S: Subscriber + for<'a> LookupSpan<'a>,
Source§fn on_event(&self, event: &Event<'_>, ctx: Context<'_, S>)
fn on_event(&self, event: &Event<'_>, ctx: Context<'_, S>)
Source§fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>)
fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>)
Attributes
and Id
.Source§fn on_register_dispatch(&self, subscriber: &Dispatch)
fn on_register_dispatch(&self, subscriber: &Dispatch)
Subscriber
. Read moreSource§fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest
Subscriber::register_callsite
. Read moreSource§fn enabled(&self, metadata: &Metadata<'_>, ctx: Context<'_, S>) -> bool
fn enabled(&self, metadata: &Metadata<'_>, ctx: Context<'_, S>) -> bool
true
if this layer is interested in a span or event with the
given metadata
in the current Context
, similarly to
Subscriber::enabled
. Read moreSource§fn on_record(&self, _span: &Id, _values: &Record<'_>, _ctx: Context<'_, S>)
fn on_record(&self, _span: &Id, _values: &Record<'_>, _ctx: Context<'_, S>)
Id
recorded the given
values
.Source§fn on_follows_from(&self, _span: &Id, _follows: &Id, _ctx: Context<'_, S>)
fn on_follows_from(&self, _span: &Id, _follows: &Id, _ctx: Context<'_, S>)
span
recorded that it
follows from the span with the ID follows
.Source§fn on_enter(&self, _id: &Id, _ctx: Context<'_, S>)
fn on_enter(&self, _id: &Id, _ctx: Context<'_, S>)
Source§fn on_exit(&self, _id: &Id, _ctx: Context<'_, S>)
fn on_exit(&self, _id: &Id, _ctx: Context<'_, S>)
Source§fn on_close(&self, _id: Id, _ctx: Context<'_, S>)
fn on_close(&self, _id: Id, _ctx: Context<'_, S>)
Source§fn on_id_change(&self, _old: &Id, _new: &Id, _ctx: Context<'_, S>)
fn on_id_change(&self, _old: &Id, _new: &Id, _ctx: Context<'_, S>)
Source§fn and_then<L>(self, layer: L) -> Layered<L, Self, S>
fn and_then<L>(self, layer: L) -> Layered<L, Self, S>
Layer
, returning a Layered
struct implementing Layer
. Read moreSource§fn with_subscriber(self, inner: S) -> Layered<Self, S>where
Self: Sized,
fn with_subscriber(self, inner: S) -> Layered<Self, S>where
Self: Sized,
Layer
with the given Subscriber
, returning a
Layered
struct that implements Subscriber
. Read more