| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Runtime.Log
Description
The structured-logging pipeline: the katip LogEnv every layer attaches context to, in
the format and at the severity floor configuration chose. JsonLog writes one compact JSON
object per line to stdout, the shape a log collector's stdout autodiscovery consumes directly,
and ConsoleLog the human-readable bracketed form for local development. Colour is forced off
either way, so a captured JSON line stays valid JSON. A bearer token reaches no field here: it
is the redacted Secret of Ecluse.Core.Credential, and a URL is reduced to its authority
before it names anything in a line.
Synopsis
- data LogFormat
- parseLogFormat :: Text -> Either Text LogFormat
- data LogLevel
- parseLogLevel :: Text -> Either Text LogLevel
- newLogEnv :: LogFormat -> LogLevel -> DdContext -> Environment -> IO LogEnv
- moduleField :: Text -> SimpleLogPayload
- moduleContext :: LogEnv -> Text -> KatipContextT m a -> m a
- logLine :: LogEnv -> SimpleLogPayload -> Severity -> Text -> IO ()
- moduleLog :: LogEnv -> Text -> Severity -> Text -> IO ()
- data DdContext = DdContext {}
- data DdSpan = DdSpan {}
- ddField :: DdContext -> SimpleLogPayload
Log format
The on-the-wire shape of the log stream, selected by configuration.
Constructors
| JsonLog | One compact JSON object per line to stdout (JSONL): the in-container default a log collector's stdout JSON parsing consumes. |
| ConsoleLog | The human-readable bracketed form, for local development. |
Instances
| WireVocab LogFormat Source # | |
Defined in Ecluse.Runtime.Log.Internal | |
| Generic LogFormat Source # | |
Defined in Ecluse.Runtime.Log.Internal | |
| Show LogFormat Source # | |
| Eq LogFormat Source # | |
| Universe LogFormat Source # | |
Defined in Ecluse.Runtime.Log.Internal | |
| type Rep LogFormat Source # | |
parseLogFormat :: Text -> Either Text LogFormat Source #
Parse a LogFormat from its wire name, naming the accepted set on failure.
>>>parseLogFormat "json"Right JsonLog
>>>parseLogFormat "yaml"Left "unknown log format \"yaml\" (expected one of: json, console)"
Log level
The lowest severity the stream keeps, selected by configuration. The four values are the
ones severityStatus renders into the status field.
Constructors
| DebugLevel | Keep everything, the per-decision diagnostics included. |
| InfoLevel | The default: normal runtime conditions and worse. |
| WarnLevel | Warnings and worse. |
| ErrorLevel | Errors alone. |
Instances
parseLogLevel :: Text -> Either Text LogLevel Source #
Parse a LogLevel from its wire name, naming the accepted set on failure.
>>>parseLogLevel "warn"Right WarnLevel
>>>parseLogLevel "trace"Left "unknown log level \"trace\" (expected one of: debug, info, warn, error)"
Pipeline construction
newLogEnv :: LogFormat -> LogLevel -> DdContext -> Environment -> IO LogEnv Source #
Build the LogEnv: one stdout scribe in format that keeps items at or above level.
The formatter stamps logIdentity on every line, so a line outside a span names its service.
Structured context
moduleField :: Text -> SimpleLogPayload Source #
The structured context naming the source module a log line came from. Compose it into a
log site's payload so a reader filters the stream by emitter without the katip namespace.
Log lines outside a handler
moduleContext :: LogEnv -> Text -> KatipContextT m a -> m a Source #
Run action in a context naming its emitting module. A phase that holds no Handler
reader, such as boot or a worker loop, enters the log stream this way.
logLine :: LogEnv -> SimpleLogPayload -> Severity -> Text -> IO () Source #
Log one line through a composition-root LogEnv under payload, for a caller whose
context is a payload rather than a module name.
moduleLog :: LogEnv -> Text -> Severity -> Text -> IO () Source #
One line under a moduleField naming the emitting module and nothing else.
Datadog trace correlation
The unified-service identity stamped onto every log line, resolved by Ecluse.Runtime.Telemetry.Resolve so logs and traces share one identity.
Constructors
| DdContext | |
The active span's ids, rendered in the Datadog form by
Ecluse.Runtime.Telemetry.Correlation. They are Text, so this type needs no OTel dependency.
Constructors
| DdSpan | |
Instances
ddField :: DdContext -> SimpleLogPayload Source #
The dd object as a katip payload under the dd key. Install it as the initial
context of a request or worker scope so every line there carries that scope's active span.