Struct tracing_journald::Layer
source[−]pub struct Layer { /* private fields */ }
Expand description
Sends events and their fields to journald
journald conventions for structured field names differ from typical tracing idioms, and journald
discards fields which violate its conventions. Hence, this layer automatically sanitizes field
names by translating .
s into _
s, stripping leading _
s and non-ascii-alphanumeric
characters other than _
, and upcasing.
Levels are mapped losslessly to journald PRIORITY
values as follows:
ERROR
=> Error (3)WARN
=> Warning (4)INFO
=> Notice (5)DEBUG
=> Informational (6)TRACE
=> Debug (7)
Note that the naming scheme differs slightly for the latter half.
The standard journald CODE_LINE
and CODE_FILE
fields are automatically emitted. A TARGET
field is emitted containing the event’s target. Enclosing spans are numbered counting up from
the root, and their fields and metadata are included in fields prefixed by Sn_
where n
is
that number.
User-defined fields other than the event message
field have a prefix applied by default to
prevent collision with standard fields.
Implementations
Construct a journald layer
Fails if the journald socket couldn’t be opened. Returns a NotFound
error unconditionally
in non-Unix environments.
Sets the prefix to apply to names of user-defined fields other than the event message
field. Defaults to Some("F")
.
Sets the syslog identifier for this logger.
The syslog identifier comes from the classic syslog interface (openlog()
and syslog()
) and tags log entries with a given identifier.
Systemd exposes it in the SYSLOG_IDENTIFIER
journal field, and allows
filtering log messages by syslog identifier with journalctl -t
.
Unlike the unit (journalctl -u
) this field is not trusted, i.e. applications
can set it freely, and use it e.g. to further categorize log entries emitted under
the same systemd unit or in the same process. It also allows to filter for log
entries of processes not started in their own unit.
See Journal Fields and journalctl for more information.
Defaults to the file name of the executable of the current process, if any.
Returns the syslog identifier in use.
Trait Implementations
Notifies this layer that a new span was constructed with the given
Attributes
and Id
. Read more
Notifies this layer that a span with the given Id
recorded the given
values
. Read more
Notifies this layer that an event has occurred.
Performs late initialization when attaching a Layer
to a
Subscriber
. Read more
Registers a new callsite with this layer, returning whether or not
the layer is interested in being notified about the callsite, similarly
to Subscriber::register_callsite
. Read more
Returns true
if this layer is interested in a span or event with the
given metadata
in the current Context
, similarly to
Subscriber::enabled
. Read more
Notifies this layer that a span with the ID span
recorded that it
follows from the span with the ID follows
. Read more
Notifies this layer that a span with the given ID was entered.
Notifies this layer that the span with the given ID was exited.
Notifies this layer that the span with the given ID has been closed.
Notifies this layer that a span ID has been cloned, and that the subscriber returned a different ID. Read more
Composes this layer around the given Layer
, returning a Layered
struct implementing Layer
. Read more
Composes this Layer
with the given Subscriber
, returning a
Layered
struct that implements Subscriber
. Read more