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

hlogr

v0.0.7

Published

Opinionated drop-in request logger for Hapi.js

Downloads

6

Readme

hlogr

CI NPM version

An opinionated drop-in request logger for Hapi.js servers. Supports custom formats and write targets.

Install

npm install hlogr

Quick Start

import Hapi from "@hapi/hapi";
import hlogr from "hlogr";

export let server: Server;

const init = async (): Promise<Server> => {
  server = Hapi.server({ /* config */ });
  await server.register(hlogr);
  // other setup
  return server;
};

init().then(() => server.start());

This will log requests in the following format by default:

18:53:28 | 200 |   53ms | 192.168.1.10 |   GET   | /user/123 | -
19:15:33 | 200 |   46ms | 192.168.1.22 |   GET   | /health | -
19:45:33 | 500 |   53ms | 10.0.0.8     |   POST  | /api/upload | Invalid request
20:04:22 | 200 |  403ms | 172.17.0.1   |   GET   | /image/42 | -
20:10:19 | 404 |   10ms | 192.168.1.15 |   GET   | /icons/dev.png | Not Found
20:15:33 | 200 |   60ms | 10.0.0.2     |   GET   | /health | -
20:16:49 | 200 |    2ms | 192.168.1.30 |  DELETE | /users/999 | -

Customizations

Log Format

The plugin ships a few built-in log formats.

import hlogr, { LogFormats } from "hlogr";

await server.register({
  plugin: hlogr,
  options: {
    format: LogFormats.JSON, // default: LogFormats.DEFAULT
  },
});

Available options: DEFAULT, COMMON, COMBINED, JSON and ECS.

You can also use the building blocks from FormatParams to define your own log structure.

await server.register({
  plugin: hlogr,
  options: {
    format: ({ time, method, path, statusCode, latency, remoteAddress }) =>
      `${time} | ${statusCode} | ${latency}ms | ${remoteAddress} | ${method} | ${path}\n`,
  },
});

This is useful when creating formatters for each of the parameter. See format DEFAULT for an example.

Custom Write Target

By default, logs are written to process.stdout. You can provide your own write target by providing a callback for the writer.

await server.register({
  plugin: hlogr,
  options: {
    writer: (log) => {
      // write to a file, external service, etc.
      service.send(log);
    },
  },
});

IP Extraction

The getIp function can be used to manually extract request's origin IP address based on incoming headers or other properties.

// using a third-party library
// import { getClientIp } from "@supercharge/request-ip";

await server.register({
  plugin: hlogr,
  options: {
    // getIp: getClientIp, // or implement manually
    getIp: (request) => {
      return request.headers["x-real-ip"];
    },
  },
});

Control Logging

The plugin has a kill switch to disable logging.

await server.register({
  plugin: hlogr,
  options: {
    enabled: false,
  },
});

Development

Tested with Node.js v20+.

git clone https://github.com/gouravkhunger/hlogr
cd hlogr
npm install

# run demo server
npm run dev

# other commands
npm run check-types lint test

License

MIT