Skip to main content

Logger

walkerOS provides a centralized logging system that enables consistent logging across the collector, sources, and destinations. The logger supports four log levels and provides scoped logging for better debugging.

Configuration

Configure logging when initializing the collector:

Loading...

Log levels

LevelValueDescription
ERROR0Only errors (default)
WARN1Errors and warnings
INFO2Errors, warnings, and informational
DEBUG3All messages including debug information

Using the logger

The logger is automatically available in destination and source contexts:

In destinations

Loading...

In sources

Loading...

Logger API

Methods

MethodDescription
error(message, context?)Log an error message
warn(message, context?)Log a warning (degraded state, config issues)
info(message, context?)Log an informational message
debug(message, context?)Log a debug message
throw(message, context?)Log an error and throw an exception (returns never)
json(data)Output structured JSON data
scope(name)Create a scoped logger with a prefixed scope

Error handling

The logger accepts Error objects directly and automatically extracts relevant information:

Loading...

Throwing errors

Use logger.throw() to log an error and throw in a single call:

Loading...

Scoped loggers

Scoped loggers prefix log messages with context information, making it easier to trace logs to their origin:

Loading...

Custom handler

For advanced use cases like sending logs to external services, configure a custom handler:

Loading...

The handler receives:

ParameterTypeDescription
levelLevelLog level enum (ERROR=0, WARN=1, INFO=2, DEBUG=3)
messagestringThe log message
contextLogContextAdditional context object
scopestring[]Array of scope names
originalHandlerDefaultHandlerThe default console handler

Testing

Use the mock logger utility for testing destinations and sources:

Loading...

The mock logger provides jest mock functions for all logger methods plus:

  • scopedLoggers: Array of scoped loggers created via scope()
💡 Need implementation support?
elbwalker offers hands-on support: setup review, measurement planning, destination mapping, and live troubleshooting. Book a 2-hour session (€399)