constructor
Signature
Section titled âSignatureâconstructor(config?: ZylogConfig)Description
Section titled âDescriptionâThe constructor initializes the loggerâs internal state, merges user-provided configuration with library defaults, and registers signal listeners for SIGINT, SIGTERM, and exit.
Parameters
Section titled âParametersâ| Parameter | Type | Description |
|---|---|---|
config | ZylogConfig | Optional object to customize prefixes, levels, and formatting. |
Examples
Section titled âExamplesâBasic Initialization
Section titled âBasic InitializationâStandard setup for a console-only logger.
import { Zylog } from 'zylog';
const log = new Zylog({ prefix: 'app', level: 'info',});Production Setup
Section titled âProduction SetupâConfiguring multi-file output for different severity levels.
const log = new Zylog({ level: 'debug', streams: { all: 'logs/combined.log', levels: { error: 'logs/critical-errors.log', fatal: 'logs/system-crashes.log', }, },});
// Initialize the file streams after constructionlog.createStream();Custom Formatting
Section titled âCustom FormattingâOverriding labels and disabling colors for specific environments.
const log = new Zylog({ labels: { warn: '!!', error: 'ERR', }, colors: 0, // Completely disable ANSI colors});