loggry
v0.4.67
Published
Lightweight NodeJS logger bus
Downloads
877
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 loggry
YARN
yarn add loggry
NPM
npm install --save loggry
Usage
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