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

Source #data LogConfig

How the worker emits its own logs.

Constructors

LogConfig 

Fields

Source #data LogDestination

Where Arbiter writes log output.

Constructors

LogStdout

Log to stdout (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. Use this callback to send Arbiter logs to an application logging system.

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 (silent mode)

Source #defaultLogConfig :: LogConfig

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

Source #silentLogConfig :: LogConfig

Silent log configuration: discards all logs.

Log Levels

Source #data LogLevel

Log severity levels.

Constructors

Debug 
Info 
Warning 
Error 

Emitting

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

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

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

tryLog an exception at Warning under label.

Source #recoveryLevel :: LogConfig -> LogLevel -> LogLevel

The gentlest level a recovery can take and still reach a log that showed the failure.

Source #hubLogFor :: LogConfig -> HubLog

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

Repeat suppression

#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.

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

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

Source #data FailureGates

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

Source #newFailureGates :: MonadIO m => m FailureGates

An empty gate store.

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

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

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