Skip to main content
@faremeter/logs provides a lightweight logging abstraction used across all faremeter packages. It supports pluggable backends, log levels, and structured context objects.

Basic usage

Get a logger without any explicit configuration. The library auto-resolves a backend (LogtapeBackend if @logtape/logtape is installed, otherwise ConsoleBackend).
The subsystem array passed to getLogger identifies the component producing the log entry. Backends use this for filtering and categorization.

Configuring the app

Call configureApp once at startup to set the log level and optionally choose a backend:

ConfigureAppArgs

Log levels

The LogLevels constant defines all available levels in order of increasing severity:
Messages below the configured level are suppressed.

Context objects

Every log method accepts an optional context object as the second argument:
Context values can be any serializable type (Record<string, unknown>). Backends determine how context is rendered.

Custom backend

Implement the LoggingBackend interface to route logs to any destination:
Pass it to configureApp:

LogtapeBackend

For structured logging in production, use the LogtapeBackend from @faremeter/logs/logtape. This is the default backend when @logtape/logtape is installed.
LogtapeBackend integrates with the logtape ecosystem, enabling file sinks, JSON formatting, and other logtape transports.

Further reading