prelude

@prelude/log · v2.0.1

SourceAPI referenceChangelognpm

Log package

A lightweight, flexible TypeScript logging library with configurable severity levels and pluggable log targets.

Features

Usage

pnpm i -E @prelude/log
import * as Fs from 'node:fs/promises'
import Log from '@prelude/log'

// Create a logger with namespace
const log = new Log('my-module')

// Log at different severity levels
log.info('application started')
log.debug('processing request', { id: 123 })

// Use the rescue pattern for error handling
const file = await Fs
  .readFile('config.json', 'utf-8')
  .catch(log.rescue('error', 'Error while trying to read file', undefined))

// Continue with file if available
if (file) {
  // Process file
}

Use with:

LOG=debug tsx my-script.ts

License

This package is dedicated to the public domain under CC0 1.0.