#[non_exhaustive]pub struct LogLine {
pub target: Cow<'static, str>,
pub message: String,
pub severity: Severity,
pub fields: Vec<KeyValue>,
pub file: Option<String>,
pub line: Option<u32>,
pub trace: Option<TraceContext>,
pub entry_point: Option<EntryPoint>,
pub error: Option<LoggedError>,
}Expand description
A log line, in the shape every logging integration can produce.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.target: Cow<'static, str>The tracing or log target that wrote the line, like my_app::billing.
It is the module path, unless the code sets another target. Flare shows it
as the target of the log.
message: StringThe message, like order placed.
severity: SeverityThe severity. Flare’s Level is derived from it.
fields: Vec<KeyValue>The structured fields of the line, like order_id = 7.
file: Option<String>The source file that wrote the line, when known.
line: Option<u32>The line number in the source file, when known.
trace: Option<TraceContext>The trace and span the line happened in, when there is one.
entry_point: Option<EntryPoint>The entry point of the closest tracing span around the line that has an
entry point, like the server span of a request. None means that no
span around the line has one.
Integrations must set this field when they send the line as a log record
or as a report. The log record and the report do not search the spans
again, because the current span can differ from the span of the line, for
example for an event with parent: None. An integration can leave this
field None when a nested scope has an entry point, because that entry
point wins over every span. LogLine::search_entry_point sets this field
and skips the search in that case.
error: Option<LoggedError>The error the line logs, like the error field of a tracing event. When
the line is sent as an error report, the report shows this error instead of
the message.
Implementations§
Source§impl LogLine
impl LogLine
Sourcepub fn new<T, M>(target: T, message: M, severity: Severity) -> Self
pub fn new<T, M>(target: T, message: M, severity: Severity) -> Self
Creates a line with a target, a message and a severity. The other fields
start empty, and integrations set them afterwards. For a log record or a
report, integrations must also set LogLine::entry_point.
Sourcepub fn search_entry_point<F>(&mut self, search_spans: F)
pub fn search_entry_point<F>(&mut self, search_spans: F)
Sets LogLine::entry_point to the result of search_spans, which finds
the entry point of the closest tracing span around the line. This function
does not call search_spans when a nested scope has an entry point,
because that entry point wins over every span.
Integrations call this function on the thread that made the line, for a line that they send as a log record or as a report.
Sourcepub fn send(self, client: &Client, targets: Targets)
pub fn send(self, client: &Client, targets: Targets)
Delivers the line to the given targets.
This function sends the report before it records the breadcrumb. That way, the timeline of the report shows what happened before this line, and not this line itself. The log record comes last, because it takes the message and the fields of the line instead of a copy.