A LogAnnotation
describes a particular type of statically-typed log
annotation applied to log lines.
A LogAnnotation
describes a particular type of statically-typed log
annotation applied to log lines. Log annotations combine in user-defined
ways, which means they can have arbitrary structure. In the end, however,
it must be possible to render each log annotation as a string.
myEffect @@ UserId("jdoe")
A LogContext
stores context associated with logging operations.
A LogFormat represents a DSL to describe the format of text log messages.
A LogFormat represents a DSL to describe the format of text log messages.
import zio.logging.LogFormat._ timestamp.fixed(32) |-| level |-| label("message", quoted(line))
The logContext fiber reference is used to store typed, structured log annotations, which can be utilized by backends to enrich log messages.
The logContext fiber reference is used to store typed, structured log annotations, which can be utilized by backends to enrich log messages.
Because logContext is an ordinary zio.FiberRef, it may be get, set, and updated like any other fiber reference. However, the idiomatic way to interact with logContext is by using zio.logging.LogAnnotation.
For example:
myResponseHandler(request) @@ UserId(request.userId)
This code would add the structured log annotation LogAnnotation.UserId
to all log messages emitted by the myResponseHandler(request)
effect.