Logger
Type Alias: Logger
Section titled “Type Alias: Logger”Logger =
object
Defined in: types.ts:192
The logger interface.
Properties
Section titled “Properties”addTransport
Section titled “addTransport”addTransport: (
transport) =>void
Defined in: types.ts:263
Add a transport at runtime. Affects this logger and its children.
Parameters
Section titled “Parameters”transport
Section titled “transport”Returns
Section titled “Returns”void
child: {(
context):Logger; (name,context?):Logger; }
Defined in: types.ts:237
Create a child logger.
child(context)prepends a context object to every record.child(name)/child(name, context)nests a string scope (parent:child) that transports can render as a prefix — ideal for hierarchical CLI loggers (app,app:manifest).
Children share the parent’s transports (including any added later via
addTransport) and inherit its level, timestamp format, and
onTransportError.
Call Signature
Section titled “Call Signature”(
context):Logger
Parameters
Section titled “Parameters”context
Section titled “context”Record<string, unknown>
Returns
Section titled “Returns”Logger
Call Signature
Section titled “Call Signature”(
name,context?):Logger
Parameters
Section titled “Parameters”string
context?
Section titled “context?”Record<string, unknown>
Returns
Section titled “Returns”Logger
debug: (
message,context?) =>void
Defined in: types.ts:197
Parameters
Section titled “Parameters”message
Section titled “message”string
context?
Section titled “context?”Record<string, unknown>
Returns
Section titled “Returns”void
error: (
messageOrError,context?) =>void
Defined in: types.ts:204
Log an error. Pass an Error instance to capture name/message/stack/cause/code, or a message string with optional context.
Parameters
Section titled “Parameters”messageOrError
Section titled “messageOrError”string | Error
context?
Section titled “context?”Record<string, unknown>
Returns
Section titled “Returns”void
fatal: (
messageOrError,context?) =>void
Defined in: types.ts:205
Parameters
Section titled “Parameters”messageOrError
Section titled “messageOrError”string | Error
context?
Section titled “context?”Record<string, unknown>
Returns
Section titled “Returns”void
flush: () =>
Promise<TransportStatus[]>
Defined in: types.ts:278
Flush all transports. Returns a per-transport status so callers can detect drains that failed (e.g. before exiting a serverless handler).
The promise always resolves; failures appear as { ok: false, error }
entries in the returned array and are also reported via
LoggerConfig.onTransportError if configured.
Returns
Section titled “Returns”Promise<TransportStatus[]>
info: (
message,context?) =>void
Defined in: types.ts:198
Parameters
Section titled “Parameters”message
Section titled “message”string
context?
Section titled “context?”Record<string, unknown>
Returns
Section titled “Returns”void
isLevelEnabled
Section titled “isLevelEnabled”isLevelEnabled: (
level) =>boolean
Defined in: types.ts:194
Returns true if the given level would be emitted.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”boolean
log: (
input) =>void
Defined in: types.ts:223
Low-level structured log with full control over the record — including
meta, kind, and args, which the convenience methods don’t expose.
The escape hatch for wrappers that build their own entries.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Example
Section titled “Example”log.log({ level: "info", message: "built %s in %dms", args: ["index.js", 12], kind: "success", meta: { entry: hostEntry },});mark: (
label,options?) => (extraContext?) =>number
Defined in: types.ts:257
Start a performance marker. Returns a function that, when called, emits a
record with durationMs measured from the start and returns that
duration so callers can reuse the number.
The duration is returned even when the level is disabled (no record is emitted in that case).
Parameters
Section titled “Parameters”string
options?
Section titled “options?”level?
Section titled “level?”Returns
Section titled “Returns”(extraContext?) => number
Example
Section titled “Example”const end = logger.mark("query.users");const users = await db.users.find();const ms = end({ count: users.length }); // logs, and ms is reusableremoveTransport
Section titled “removeTransport”removeTransport: (
name?) =>number
Defined in: types.ts:268
Remove transports at runtime. With a name, removes every transport with
that name; without one, removes all. Returns the number removed.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”number
trace: (
message,context?) =>void
Defined in: types.ts:196
Parameters
Section titled “Parameters”message
Section titled “message”string
context?
Section titled “context?”Record<string, unknown>
Returns
Section titled “Returns”void
warn: (
message,context?) =>void
Defined in: types.ts:199
Parameters
Section titled “Parameters”message
Section titled “message”string
context?
Section titled “context?”Record<string, unknown>
Returns
Section titled “Returns”void