npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nodifier/loguru

v1.0.1

Published

Utils for logging

Downloads

9

Readme

@nodifier/loguru

A simple and flexible logging utility for Node.js, inspired by Python's loguru. Provides easy-to-use logging with support for multiple transports (console, file), custom formatting, log levels, and context.

Features

  • Simple API for logging at different levels (info, warn, error, debug, fatal)
  • Pluggable transports (console, file, custom)
  • Customizable log formats (JSON, plain text, etc.)
  • Context support via child loggers
  • TypeScript support

Installation

npm install @nodifier/loguru

Basic Usage (Singleton Logger)

import { logger } from '@nodifier/loguru';

logger.info('Hello, world!');
logger.warn('This is a warning');
logger.error('Something went wrong', { error: new Error('Oops') });
logger.debug('Debugging info', { data: { foo: 'bar' } });

Creating a Custom Logger Instance

import { Logger, ConsoleTransport } from '@nodifier/loguru';

const logger = new Logger({
  level: 'DEBUG',
  serviceName: 'MyService',
  transports: [new ConsoleTransport()],
});

logger.info('Custom logger instance!');

Using File Transport

import { Logger, FileTransport } from '@nodifier/loguru';

const logger = new Logger({
  level: 'INFO',
  serviceName: 'FileService',
  transports: [
    new FileTransport({ path: './logs/app.log', maxSize: 1024 * 1024 }),
  ],
});

logger.info('This will be written to app.log');

Using JSON Formatting

import { Logger, ConsoleTransport, JsonFormatter } from '@nodifier/loguru';

const logger = new Logger({
  level: 'INFO',
  serviceName: 'JsonService',
  transports: [new ConsoleTransport()],
  // The formatter is used internally by transports, but you can customize output in your own transport
});

// To format manually:
import { JsonFormatter } from '@nodifier/loguru';
const formatter = new JsonFormatter();
const formatted = formatter.format({
  timestamp: new Date().toISOString(),
  level: 'INFO',
  service: 'JsonService',
  message: 'Log as JSON',
});
console.log(formatted);

Adding Context with Child Loggers

import { logger } from '@nodifier/loguru';

const userLogger = logger.child({ userId: '1234' });
userLogger.info('User-specific log');

API Reference

  • Logger(config: LoggerConfig): Create a new logger instance.
    • config.level: Minimum log level (DEBUG, INFO, WARN, ERROR, FATAL)
    • config.serviceName: Name of the service/application
    • config.transports: Array of transports (e.g., ConsoleTransport, FileTransport)
    • config.defaultMeta: Default metadata to include with every log
    • config.customLevels: Custom log levels (optional)
  • logger.info(message, meta?): Log an info message
  • logger.warn(message, meta?): Log a warning
  • logger.error(message, meta?): Log an error
  • logger.debug(message, meta?): Log a debug message
  • logger.fatal(message, meta?): Log a fatal error
  • logger.child(meta): Create a child logger with additional context

Transports

  • ConsoleTransport(level?): Log to the console (stdout)
  • FileTransport({ path, maxSize? }, level?): Log to a file with optional rotation

Formatter

  • JsonFormatter: Formats log entries as JSON strings

License

MIT