Home > @opengovsg/logging > Logger > scope
Logger.scope() method
Return a **new** logger whose action is set to action (the most-specific "leaf"; a per-call action still wins over it). The new logger inherits this logger's context, **merged** with any additional context provided here. Does not mutate the parent.
Unlike pino.child, scope **merges** context (child *replaces* it), which is why it is scope, not child. The pino child is createBaseLogger.
Signature:
typescript
scope(options: {
action: string;
context?: LogInput['context'];
}): Logger;Parameters
| Parameter | Type | Description |
|---|---|---|
| options | { action: string; context?: LogInput['context']; } | action: the action to set. context: additional metadata merged with the parent context. |
Returns:
A new Logger scoped to the given action.