async-logger package
Non-blocking logger for @imqueue services: writes to the console without holding up the caller, and ships the same records to file or HTTP transports configured entirely from the environment.
The default export is a ready-to-use Logger already configured from LOGGER_TRANSPORTS and LOGGER_METADATA, so the common case needs no construction and no wiring:
import logger from '@imqueue/async-logger';
logger.info('service started on port %s', port);
Remarks
Console writes are deferred with setTimeout, which is what keeps a burst of logging from blocking the event loop — and the reason for the package name. Two consequences follow: log output can appear after code that ran later, and a process that exits immediately after logging may lose the tail. Call it a tick before exiting if the last lines matter.
Transports are declared as JSON in LOGGER_TRANSPORTS. The placeholders %name and %version are substituted from the running service's own package.json, so one config can be shared across services:
export LOGGER_TRANSPORTS='[{"type":"http","options":{"ssl":true,"port":443,"host":"http-intake.logs.datadoghq.com","path":"/v1/input/<API_KEY>"},"enabled":true}]'
export LOGGER_METADATA='{"ddsource":"%name %version","ddtags":"env: dev"}'
With no transports configured the logger still works — console only. That is the intended local-development mode, not a misconfiguration.
Classes
|
Class |
Description |
|---|---|
|
Logger that writes to the console without blocking the caller and forwards the same records to any configured winston transports. |
Functions
|
Function |
Description |
|---|---|
|
Renders | |
|
Parses the default record metadata out of | |
|
Constructs a winston transport of the named type. | |
|
Reads the running service's own name and version, used to expand the | |
|
Parses the transport declarations out of |
Interfaces
|
Interface |
Description |
|---|---|
|
Explicit configuration for a Logger, replacing what it would otherwise read from the environment. | |
|
The logger contract shared across | |
|
A JSON array — any number of AnyJson values. | |
|
A JSON object — string keys, AnyJson values. This is the type of the logger's default metadata. | |
|
One transport declaration — the shape of each element in the |
Variables
|
Variable |
Description |
|---|---|
|
A Logger configured from the environment, constructed at import time. |
Type Aliases
|
Type Alias |
Description |
|---|---|
|
Any value that survives |
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.