Log Lifecycle

The complete journey of a log — from call to console.

The Lifecycle Flow

Every log call follows a predictable pipeline of four stages:

logger.log() // or .fromJson() / .time()

1. Console Logger (only if debug: true)

2. Global Callback (if defined)

3. Group Callback (if group exists & has callback)

4. Specific Callback (if options.callBack provided)

Console Output

The Four Stages

1. Console Logger

Renders the visual group header and executes the logging function (console.log, console.table, or console.time). Only runs when global.debug is true.

2. Global Callback

Defined in global.callBack. Runs for every log, regardless of group. Ideal for analytics, telemetry, or custom formatting. Runs even if debug: false.

3. Group Callback

Defined per group (groups[name].callBack). Runs only for logs in that specific group. Great for group‑specific logic. Runs even if debug: false.

4. Specific Callback

Passed directly in options.callBack. Runs only for that single log, after all other callbacks. Runs even if debug: false.

Execution Order

The order is always: Console Logger → Global → Group → Specific. This predictability is key to building reliable logging pipelines.

Important: Even if debug: false (skipping stage 1), stages 2–4 still execute. This allows production telemetry without console clutter.

Error Handling

Errors in any callback are caught and logged, but the application never crashes.

See API Reference: Errors for more details.

Use Cases

Analytics

Global callback sends every log to your analytics service.

Alerts

Specific callback sends Slack alerts only for critical logs.

Transformation

Global callback enriches data (add timestamp, user ID) before output.

Environment logic

Conditional logic based on environment (dev/prod).

For working code examples, visit the Examples page.

Next: Explore the complete API Reference or see Examples in action.