Skip to content

Logger

Logger = object

Defined in: types.ts:192

The logger interface.

addTransport: (transport) => void

Defined in: types.ts:263

Add a transport at runtime. Affects this logger and its children.

Transport

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.

(context): Logger

Record<string, unknown>

Logger

(name, context?): Logger

string

Record<string, unknown>

Logger


debug: (message, context?) => void

Defined in: types.ts:197

string

Record<string, unknown>

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.

string | Error

Record<string, unknown>

void


fatal: (messageOrError, context?) => void

Defined in: types.ts:205

string | Error

Record<string, unknown>

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.

Promise<TransportStatus[]>


info: (message, context?) => void

Defined in: types.ts:198

string

Record<string, unknown>

void


isLevelEnabled: (level) => boolean

Defined in: types.ts:194

Returns true if the given level would be emitted.

LogLevel

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.

LogInput

void

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

string

LogLevel

(extraContext?) => number

const end = logger.mark("query.users");
const users = await db.users.find();
const ms = end({ count: users.length }); // logs, and ms is reusable

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.

string

number


trace: (message, context?) => void

Defined in: types.ts:196

string

Record<string, unknown>

void


warn: (message, context?) => void

Defined in: types.ts:199

string

Record<string, unknown>

void