| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Runtime.Log.Internal
Description
The severity mapping, the scribe and the formatters behind Ecluse.Runtime.Log, which
documents the pipeline and re-exports the curated surface. Importing this module opts out of
that stability promise, the convention text and bytestring use, so production code imports
the public one.
Synopsis
- data LogFormat
- parseLogFormat :: Text -> Either Text LogFormat
- data LogLevel
- parseLogLevel :: Text -> Either Text LogLevel
- severityFloor :: LogLevel -> Severity
- severityStatus :: Severity -> Text
- newLogEnv :: LogFormat -> LogLevel -> DdContext -> Environment -> IO LogEnv
- newScribe :: LogFormat -> LogLevel -> DdContext -> IO Scribe
- formatterFor :: LogItem a => LogFormat -> DdContext -> ItemFormatter a
- 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
- ddObject :: DdContext -> Value
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)"
severityFloor :: LogLevel -> Severity Source #
severityStatus :: Severity -> Text Source #
The status a katip Severity renders as. A log backend's status facet reads the
four values an operator acts on, so the eight syslog severities fold into them.
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.
formatterFor :: LogItem a => LogFormat -> DdContext -> ItemFormatter a Source #
The katip ItemFormatter a LogFormat wires into its scribe. Only the JsonLog form
stamps the dd identity, and ConsoleLog drops it.
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.