Skip to content

Home > @opengovsg/logging > LogInput

LogInput interface ​

The shape of a single log call: a message, an optional action naming the operation, and optional structured context, error, and merged fields.

action is a single, optional string naming the current operation. Scoping (Logger.scope() / Logger.setAction()) sets the leaf action; the per-call action wins over it. Only that most-specific action is emitted.

Signature:

typescript
export interface LogInput

Properties ​

PropertyModifiersTypeDescription
action?string(Optional) The action for this call. Optional — most specific wins over the scoped path.
context?{ action?: never; error?: never; [key: string]: unknown; }(Optional) Free-form, app-owned business data, emitted as the context field. action and error are reserved at the top level and forbidden here.
error?unknown(Optional) The error to shape and attach as the error field. Any thrown value is accepted and normalised. Only valid on warn / error.
merged?Record<string, unknown>(Optional) Escape-hatch bag merged at the top level of the line. Spread first, so it can never clobber controlled fields (action, history, context).
messagestringThe log message. Keep it a stable, low-cardinality string — put variable data in context, never interpolated here (the structured-first convention).