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 |
|---|---|---|
|
Constructs a new instance of the |
Methods
|
Method |
Modifiers |
Description |
|---|---|---|
|
Logs at ERROR level. | ||
|
Logs at INFO level — routine progress worth keeping. | ||
|
Logs to the console and to every configured transport. | ||
|
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.