Skip to content

Repository files navigation

@gvray/logger

npm version License: MIT

A development-time logger for Node.js and browsers — colored console output, deep object inspection, a middleware pipeline, and hierarchical namespaces. Zero runtime dependencies, TypeScript-first.

Not for production log shipping. This library is optimized for humans reading a console while developing (colors, pretty-printed objects, sync in-process listeners). To ship logs to a platform — with async batching, retry, sampling, and trace correlation — use Pino for logs or Sentry for errors.

Documentation

Full documentation with live, runnable examples: https://gvray.github.io/logger/

Installation

npm install @gvray/logger

Quick Start

import { Logger, LogLevel } from '@gvray/logger';

const logger = new Logger({
  level: LogLevel.DEBUG,
  timestamp: 'time',
  namespace: 'app',
});

logger.info('Server started on port', 3000);
logger.debug('Config:', { env: 'production', debug: false });
logger.error('Connection failed:', new Error('timeout'));

// Namespaces & child loggers
const db = logger.child('db');
db.info('Connected'); // [app:db] [INFO] Connected

// Middleware
import { prefixMiddleware, redactMiddleware } from '@gvray/logger';
logger.use(prefixMiddleware('[API]'));
logger.use(redactMiddleware(['password', /token/i]));

Development

pnpm install
pnpm docs:dev      # docs site with live examples (HMR on src/)
pnpm build         # build the library to dist/
pnpm test          # run jest

License

MIT

About

Logging utility with different log levels with timestamp options.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Packages

Used by

Contributors

Languages