Logger class

Logger that writes to the console without blocking the caller and forwards the same records to any configured winston transports.

Signature:

export declare class Logger implements ILogger 

Implements: ILogger

Remarks

Implements ILogger, so it drops into anything in @imqueue that accepts a logger — IMQClient, IMQService, RedisCache — replacing the default synchronous console.

Console output is scheduled with setTimeout rather than written inline. That is the point of the package: a service logging heavily does not pay for it on the request path. It also means ordering against synchronous code is not guaranteed, and output queued at the moment of process.exit() is lost.

Transports are optional. Constructed with none — the default when LOGGER_TRANSPORTS is unset — this behaves as an async console logger and never touches winston.

Example

import { Logger } from '@imqueue/async-logger';

// configured from LOGGER_TRANSPORTS / LOGGER_METADATA
const logger = new Logger();

// or explicitly, e.g. to tag one subsystem differently
const audit = new Logger({
    transports: [{ type: 'file', options: { filename: 'audit.log' }, enabled: true }],
    metadata: { subsystem: 'audit' },
});

audit.info('user %s signed in', userId);

Constructors

Constructor

Modifiers

Description

(constructor)(options)

Constructs a new instance of the Logger class

Methods

Method

Modifiers

Description

error(args)

Logs at ERROR level.

info(args)

Logs at INFO level — routine progress worth keeping.

log(args)

Logs to the console and to every configured transport.

warn(args)

Logs at WARN level — something recovered from, but worth seeing.

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.