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

@vuedapt/logger

v1.0.0

Published

A simple, colorful logging package for Node.js

Readme

@vuedapt/logger

A production-ready logging library for Node.js with automatic HTTP request logging, color-coded log levels, and intelligent environment-based configuration. Features zero-configuration Express middleware for seamless HTTP logging and built-in production optimizations.

Changelog

See CHANGELOG.md.

Installation

npm install @vuedapt/logger

Usage

ES6 (ES Modules)

import logger from '@vuedapt/logger';

// Info logs
logger.info('Application started successfully');

// Warn logs
logger.warn('This is a warning message');

// Error logs
logger.error('An error occurred');

// Debug logs
logger.debug('Debug information');

// Express middleware (automatic HTTP logging for all requests)
import express from 'express';
const app = express();
app.use(logger.middleware());

ES5 (CommonJS)

const logger = require('@vuedapt/logger');

// Info logs
logger.info('Application started successfully');

// Warn logs
logger.warn('This is a warning message');

// Error logs
logger.error('An error occurred');

// Debug logs
logger.debug('Debug information');

// Express middleware (automatic HTTP logging for all requests)
const express = require('express');
const app = express();
app.use(logger.middleware());

Output Format

The default format is: YYYY-MM-DD HH:MM:SS [LEVEL] - Message

Default output (simplified):

  • 2024-01-15 14:30:45 [INFO] - Application started successfully
  • 2024-01-15 14:30:46 [WARN] - This is a warning message
  • 2024-01-15 14:30:47 [ERROR] - An error occurred
  • 2024-01-15 14:30:48 [DEBUG] - Debug information
  • 2024-01-15 14:30:49 [HTTP] - GET /api/products HTTP/1.1 200

Customization

The logger can be customized using the configure() method:

ES6 (ES Modules)

import logger from '@vuedapt/logger';

// Enable file name and line number in logs
logger.configure({ showFileInfo: true });

// Disable stack traces for errors
logger.configure({ showStackTrace: false });

// Configure multiple options at once
logger.configure({
  showFileInfo: true,
  showStackTrace: true
});

ES5 (CommonJS)

const logger = require('@vuedapt/logger');

// Enable file name and line number in logs
logger.configure({ showFileInfo: true });

// Disable stack traces for errors
logger.configure({ showStackTrace: false });

// Configure multiple options at once
logger.configure({
  showFileInfo: true,
  showStackTrace: true
});

Configuration Options

  • showFileInfo (default: false) - Show file name and line number in logs

    • When enabled: 2024-01-15 14:30:45 [INFO] - Message (app.js:42)
    • When disabled: 2024-01-15 14:30:45 [INFO] - Message
  • showStackTrace (default: !isProduction()) - Show stack traces for ERROR logs

    • Automatically disabled in production for security
    • Can be manually enabled/disabled

Log Levels

  • INFO - For informational messages
  • WARN - For warning messages
  • ERROR - For error messages
  • DEBUG - For debug messages
  • HTTP - Automatic HTTP request logging via Express middleware (method, URL, protocol, and status code)

HTTP Logging

HTTP requests are automatically logged when using the Express middleware. No configuration needed.

Status codes are color-coded:

  • 2xx - Success
  • 3xx - Redirect
  • 4xx - Client error
  • 5xx - Server error

Example output:

  • 2024-01-15 14:30:45 [HTTP] - GET /api/users HTTP/1.1 200
  • 2024-01-15 14:30:46 [HTTP] - POST /api/login HTTP/1.1 401
  • 2024-01-15 14:30:47 [HTTP] - DELETE /api/resource/123 HTTP/2 500

Automatic extraction from request/response:

  • Method: From req.method
  • URL: From req.originalUrl or req.url
  • Protocol: From req.protocol and req.httpVersion, or req.httpVersion alone
  • Status Code: From res.statusCode

Express Middleware

Use the built-in middleware for automatic logging of all HTTP requests:

ES6 (ES Modules):

import express from 'express';
import logger from '@vuedapt/logger';

const app = express();

// Add logger middleware (logs all requests automatically)
app.use(logger.middleware());

app.get('/api/users', (req, res) => {
  res.json({ users: [] });
  // Request is automatically logged when response finishes
});

ES5 (CommonJS):

const express = require('express');
const logger = require('@vuedapt/logger');

const app = express();

// Add logger middleware (logs all requests automatically)
app.use(logger.middleware());

app.get('/api/users', (req, res) => {
  res.json({ users: [] });
  // Request is automatically logged when response finishes
});

The middleware automatically logs every HTTP request with all details extracted from the request/response objects.

Production Mode

The logger automatically adjusts its behavior based on the NODE_ENV environment variable:

When NODE_ENV=production:

  • DEBUG logs are completely hidden - No debug output in production
  • Stack traces are hidden - ERROR logs don't show full stack traces (security)
  • File names and line numbers are hidden - No source location info (security)
  • Cleaner logs - Reduced verbosity for better performance

When NODE_ENV is not production (development/staging):

  • All log levels are shown (including DEBUG)
  • Full stack traces for ERROR logs
  • File names and line numbers included in all logs

Example

Development mode:

2024-01-15 14:30:45 [INFO] - Application started (app.js:42)
2024-01-15 14:30:46 [DEBUG] - Processing request (handler.js:15)
2024-01-15 14:30:47 [ERROR] - Database connection failed (db.js:23)
Error
    at Database.connect (db.js:23:10)
    at App.start (app.js:45:5)
    ...

Production mode:

2024-01-15 14:30:45 [INFO] - Application started
2024-01-15 14:30:47 [ERROR] - Database connection failed

Additional Production Recommendations

For production environments, consider:

  1. Log aggregation - Use services like Loggly, Datadog, or CloudWatch
  2. Structured logging - Consider JSON format for easier parsing (future enhancement)
  3. Log rotation - Implement log rotation to manage disk space
  4. Sensitive data - Never log passwords, tokens, or PII
  5. Rate limiting - Consider rate limiting for high-volume applications
  6. Error tracking - Integrate with error tracking services (Sentry, Rollbar)

License

MIT