arbiter-worker-0.1.0.0
arbiter-worker
Safe HaskellNone
LanguageGHC2024

Arbiter.Worker.Logger

Description

The worker's own structured JSON logging: its level, its destination, and the context every message carries. Application-level job logging belongs on ObservabilityHooks.

Synopsis

Log configuration

data LogConfigSource #

Worker log level, destination, and context.

Constructors

LogConfig 

Fields

data LogDestinationSource #

Where Arbiter writes log output.

Constructors

LogStdout

Log to stdout. The default.

LogStderr

Log to stderr.

LogFastLogger LoggerSet

Log to a custom fast-logger LoggerSet.

LogCallback (LogLevel -> Text -> [Pair] -> IO ())

Log to a user-provided callback. The callback receives the LogLevel, the plain message Text, and all structured context as [Pair] such as job information and additional context.

let cb level msg ctx = myLogger level msg ctx
in defaultLogConfig { logDestination = LogCallback cb }
LogTee LogDestination LogDestination

Emit every message to both destinations, the first one before the second.

LogDiscard

Discard all logs.

defaultLogConfig :: LogConfigSource #

Default log configuration: Info level to stdout, no additional context.

silentLogConfig :: LogConfigSource #

Silent log configuration: discards all logs.

Log levels

data LogLevelSource #

Log severity levels.

Constructors

Debug

Detail for diagnosis.

Info

Normal events.

Warning

Problems that do not stop work.

Error

Failed operations.

Failure gates

data FailureGatesSource #

Gates addressed by subject. Every subject holds its gate for the life of the store.

newFailureGates :: MonadIO m => m FailureGatesSource #

An empty gate store.

Re-exports for structured context

type Pair = (Key, Value)#

A key/value pair for an Object.

(.=) :: (KeyValue e kv, ToJSON v) => Key -> v -> kv infixr 8#

Internal

Emitting and repeat suppression for the arbiter packages. Not covered by the PVP.

tryLog :: MonadUnliftIO m => LogConfig -> LogLevel -> Text -> m ()Source #

Log a message, swallowing any exceptions from the logging infrastructure.

warnEx :: MonadUnliftIO m => LogConfig -> Text -> SomeException -> m ()Source #

tryLog an exception at Warning under label.

withIdentity :: Pair -> LogConfig -> LogConfigSource #

Add an identity field to every message.

toHubLog :: LogConfig -> HubLogSource #

Hub loggers over cfg. The hub's own events drop the identityContext.

data FailureGate#

The last failure a repeating action reported and its time. Empty while healthy.

newFailureGate :: MonadIO m => m FailureGate#

A gate for one repeating action, starting healthy.

reportOutcome :: MonadUnliftIO m => LogConfig -> LogLevel -> FailureGate -> Text -> Either SomeException a -> m ()Source #

Log an attempt only when it changes the gate. subject reads with both failed and recovered.

tryReportedOn :: MonadUnliftIO m => LogConfig -> LogLevel -> FailureGates -> Text -> m a -> m (Either SomeException a)Source #

tryReported against the gate subject names, created on first use.