API Reference
Types and options for createLogger and built-in transports.
createLogger
import { createLogger } from "@g14o/logger";
const logger = createLogger(options);Returns a Logger.
LoggerOptions
| Option | Type | Description |
|---|---|---|
formatOptions? | | Output formatting (timestamps, meta, name segment, alignment, colors, stacks). |
level? | | Minimum severity to emit. `"info"`. |
name? | | Logger name included in every log line when provided. |
redact? | | Key names to redact recursively in meta objects (case-insensitive). |
transports? | | Output transports. Default single console transport. |
FormatOptions
| Option | Type | Description |
|---|---|---|
align? | | Min terminal width for right-aligned timestamps; `80`. |
colors? | | Pretty color override ( `"auto"`. |
json? | | JSON serialization (field order and indentation). |
levels? | | Per-level glyph/label/kind overrides for console prefixes. |
meta? | | Inline meta JSON on console lines. `true`. |
name? | |
`true`. |
pretty? | | Pretty console mode (glyphs/badges). Applies to console transports. `false`. |
stack? | | Stack frames in pretty error/fatal output. `true`. |
time? | | Timestamp display. Formats: enabled with `"time"` (`HH:MM:SS`) and timezone `"utc"`. |
LevelFormatOptions
| Option | Type | Description |
|---|---|---|
fallbackSymbol? | | ASCII fallback when Unicode glyphs are unsupported. |
kind? | | Prefix kind: colored glyph or background badge. |
label? | | Uppercase label used by plain output and badges. |
symbol? | | Unicode glyph for symbol prefixes. |
JsonFormatOptions
| Option | Type | Description |
|---|---|---|
fieldOrder? | | Ordered field groups. `["timestamp", "level", "name", "message", "meta"]`. |
pretty? | | Pretty-print JSON. `false`. |
Logger
| Prop | Type | Description |
|---|---|---|
child | | Returns a child logger that merges |
debug | | Logs diagnostic details at the |
error | | Logs a recoverable failure at the |
fatal | | Logs an unrecoverable failure at the highest severity level. |
info | | Logs general operational information at the default severity level. |
start | | Logs the beginning or progress of a process at the |
success | | Logs successful completion of a process at the |
time | | Starts a timer for |
trace | | Logs fine-grained diagnostic details at the lowest severity level. |
warn | | Logs a potentially harmful or unexpected condition at the |
withRequestId | | Returns a child logger with |
Primary call shape is message, meta? for most levels. error and fatal accept error, message?. Broader (...args: unknown[]) overloads keep the type assignable to cache-style logger contracts; unsupported extra arguments are preserved under details, not printf-interpolated.
ConsoleTransport
| Option | Type | Description |
|---|---|---|
formatOptions? | | Per-transport formatting overrides (deep-merged over logger |
type | | Selects the human-readable console transport. |
JsonTransport
| Option | Type | Description |
|---|---|---|
formatOptions? | | Per-transport formatting overrides (deep-merged over logger |
type | | Selects the structured JSON transport, emitting one object per line. |
Timestamp and format types
| Type / constant | Description |
|---|---|
TimestampFormat | "time" | "time12" | "iso" | "utcString" |
TimestampTimezone | "utc" | "local" |
TimestampOption | boolean or { enabled: false } / { enabled: true; format?; timezone? } |
JsonFieldGroup | "timestamp" | "level" | "name" | "message" | "meta" |
LevelPrefixKind | "symbol" | "badge" |