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

http-debug-logger

v1.0.3

Published

A customizable HTTP request logger for Node.js and Express, ideal for debugging and monitoring backend requests with support for JSON logging, presets, and file output.

Readme

http-debug-logger

GitHub

A beginner-friendly HTTP request logger for Node.js.
Supports both native http servers and Express middleware.
Logs method, URL, status code, and response time.
Ideal for learning and debugging backend behavior in development.


Features

  • Works with native Node.js http servers and Express
  • Logs HTTP method, path, status code, and duration
  • Optional header and body logging
  • Type-safe with full TypeScript support
  • Zero external dependencies
  • Configurable output (colors, format, etc.)
  • JSON structured logging
  • [New] Write logs to a file continuously with user-specified path

Installation

# Using npm
npm install http-debug-logger

# Using yarn
yarn add http-debug-logger

Quick Start

Node.js

import http from 'http';
import {createServerLogger} from 'http-debug-logger';

const logger = createServerLogger();

const server = http.createServer((req, res) => {
    logger(req, res); // log the request
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello from Node!');
});

server.listen(3000, () => {
    console.log('Server is listening on http://localhost:3000');
});

Express

import express from 'express';
import {expressLogger} from 'http-debug-logger';

const app = express();

app.use(expressLogger()); // Use expressLogger middleware

app.get('/', (req, res) => {
    res.send('Hello from Express!');
});

app.listen(3000, () => {
    console.log('Express server running on http://localhost:3000');
});

Preset Options

To simplify setup, you can use one of the predefined logging presets by passing the preset option:

| Preset | Description | |--------------|---------------------------------------------------------------------------| | minimal | Logs only the HTTP method, URL, and status code. | | verbose | Logs method, URL, status code, response time, headers, and body. | | production | Outputs logs in JSON format (structured logging) with timestamp included. | | json | JSON-structured output with all fields |

Example Usage

Minimal Logging

import {createServerLogger} from 'http-debug-logger';

const logger = createServerLogger({preset: 'minimal'});

Verbose Logging (for development)

const logger = createServerLogger({preset: 'verbose'});

Production Logging (structured JSON format)

const logger = createServerLogger({preset: 'production'});

Note: You can still override individual options (logHeaders, logBody, timestamp, etc.) even when using a preset.


Configuration Options

| Option | Type | Default | Description | |-----------------|------------------------------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------| | prefix | string | "" | Optional prefix for each log message. | | color | boolean | true | Enable/disable colored output (using kleur). | | timestamp | boolean | true | Add a timestamp in ISO format before each log message. | | skip | (req, res) => boolean | () => false | Function that allows skipping certain logs. It returns true to skip logging. | | logHeaders | boolean | false | Log request headers (defaults to false). | | logBody | boolean | false | Log request body (defaults to false). | | format | string or (req, res) => string | "default" | Custom log message format. If a string is provided, it will be used as the format; if a function is provided, it will format the log message. | | logFilePath | string | "" | [New] File path to write logs to. | | logFileAppend | boolean | "false" | [New] Append to log file (true) or overwrite (false). |


How Configuration Works:

  • prefix: You can specify a string prefix for all your log messages.
  • color: If true, it uses kleur to colorize the logs based on the HTTP status code.
  • timestamp: If true, each log entry will include a timestamp in ISO format.
  • skip: A function to conditionally skip logging for specific requests based on your own logic (e.g., for certain paths, HTTP methods, etc.).
  • logHeaders: If enabled, logs the HTTP request headers.
  • logBody: If enabled, logs the HTTP request body (be cautious about logging sensitive data).
  • format: You can provide a custom format string or function to control how the log message is formatted.
  • logFilePath: You can provide the file path to write logs to.
  • logFileAppend: Append to log file (true) or overwrite (false).

API

createServerLogger(options?)

Creates a logger for native Node.js http servers.

expressLogger(options?)

Returns an Express middleware function that logs requests.


License

MIT