loggry
v0.4.142
Published
Lightweight NodeJS logger bus
Downloads
586
Maintainers
Readme
LOGGRY
Lightweight 0-dependency, transport agnostic, ESM and CommonJS logger bus for Node.js applications, enabling structured logging and event handling with customizable listeners and various log levels.
Instalation
PNPM
pnpm add loggryYARN
yarn add loggryNPM
npm install --save loggryUsage
In the main script
import { addListener, LogEvent } from 'loggry';
addListener((log: LogEvent) => console.log(log.level, log.message, 'at', log.timestamp));In some other place
import { debug } from 'loggry';
function myFunction() {
debug('myFunction', 'executed!');
}Built-in log levels
enum LogLevel {
silent,
fatal,
error,
warn,
info,
debug,
trace,
}Pino integration
import createPino from 'pino';
import { addListener, LogEvent } from 'loggry';
const pinoLogger = createPino();
addListener(({ level, message, details }: LogEvent) => pinoLogger[level]({ details }, message));License
License Apache-2.0 Copyright (c) 2023 Ivan Zakharchanka
