A minimal, flexible logging library for Node.js, built on top of winston. Supports ESM, with TypeScript types included.
- Simple, consistent logging API for Node.js
- Built on winston
- Supports ESM
- Default and named exports for maximum flexibility
- TypeScript type definitions included
- Supports structured JSON output with optional timestamps
- Supports child loggers with persistent context
- Serializes Error objects with name, message, and stack
- Supports configurable metadata redaction
- Supports logging primitives and arrays as meta:
log.info('msg', 42)logs{ value: 42 }log.info('msg', [1,2,3])logs{ value: [1,2,3] }
- Node.js 26 or newer
npm install @eliware/log// Example usage for ESM
import log, { log as namedLog, createLogger } from '@eliware/log';
log.info('Hello from example.mjs (default import)', { foo: 'bar' });
log.info('Primitive value', 42); // primitive value
log.info('Array value', [1,2,3]); // array value
namedLog.info('Hello from example.mjs (named import)', { foo: 'bar' });
namedLog.info('Primitive value', 'test'); // primitive value
const customLogger = createLogger({ level: 'debug' });
customLogger.debug('Custom logger debug message', { custom: true });
customLogger.debug('Primitive debug', true); // primitive valueA pre-configured logger instance. Available as both the default and a named export (log).
.info(message, meta?).debug(message, meta?).warn(message, meta?).error(message, meta?)- ...and all other winston logger methods.
Meta argument:
- If you pass a primitive or array as the second argument, it will be logged as
{ value: ... }. - If you pass an object, it will be logged as usual.
Creates a new winston logger instance.
Options:
level(string): Log level (default:process.env.LOG_LEVELor'info')transports(array): Array of winston transports (default: Console)
Returns: winston.Logger
Type definitions are included:
export declare function createLogger(options?: { level?: string; transports?: any[]; }): import('winston').Logger & {
debug(message: string, meta?: any): void;
info(message: string, meta?: any): void;
warn(message: string, meta?: any): void;
error(message: string, meta?: any): void;
};
export declare const log: import('winston').Logger & {
debug(message: string, meta?: any): void;
info(message: string, meta?: any): void;
warn(message: string, meta?: any): void;
error(message: string, meta?: any): void;
};
export default log;Use redactKeys for sensitive metadata. JSON output includes timestamps only when timestamp: true; text output safely summarizes objects and serializes BigInt values. Configure transports explicitly for tests and alternate destinations.
npm test
npm run test:gaps
npm run lint
npm run typecheck
npm run packDo not log secrets or sensitive payloads. Configure redactKeys for credential-bearing metadata and review custom transports before enabling them.
For help, questions, or to chat with the author and community, visit:


