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

@gferrand/logger-hook

v1.1.15

Published

The logger is here to help you keeping tracks of what happen in your application.

Readme

Asset manager

The logger is here to help you keeping tracks of what happen in your application.

Installing

First, install the library :

npm i @gferrand/logger-hook

... and that's it ! You can now import everything you need inside your project.

The basics

First, import it in your project :

const Logger = require('@gferrand/logger-hook').Logger;

This will give you access to the first part of the logger, the ability to save what happen withing your app in a database, and to display it in the logger dashboard.

To start using it, you must first initialize it within the project :

Logger.init( $appName, $appVersion, $appPort, $loggerUrl, $usernameCbk, $userIdCbk
    
);

Both callbacks are used to extract the user informations to enrich your logs, you must provide the way for the logger to reach the informations. E.g, for both callbacks :

(req) => req.username,
(req) => req.userId

This will tell to the logger to go inside the req object, and look for the req.username to extract the username of the user who made the call.

Once it's done, wherever you want to save an important informations, such as an user requestion a password change, you can execute one of the following :

They all work as a regular console.log, and also add the content in a database with different levels of importance.

Logger.info($information1, [$information2]);

The basic level, usually used to keep track of not so important stuff.

Logger.warn($information1, [$information2]);

The middle level, to use when you need a warning about something.

Logger.error($information1, [$information2]);

The high level, use when your app is crashing.

Logger.debug($information1, [$information2]);

Give you a log without saving it into the database.

You can either pass the req from your node route or a string. If you pass the req + a string, be sure that the req is the first argument.

There's some exemples :

 Logger.info(req, 'Creating new user');
Logger.info('Updating an user');
Logger.warn('Deleting an user');

The performance checks

First, import it :

const Performance = require('@gferrand/logger-hook').Performance;

The logger is able to monitor your application and check if it's healthy or not, giving your informations on the CPU, space left available on hard drive, ect.

Performance.init( $appName, $appVersion, $appPort, $loggerUrl, $cronLikeInterval);

Same as the previous init, except the cron interval.

The logger use the cron library to schedule stuff, please check up the documentation to know what kind of string the logger is expecting for $cronLikeInterval.

Then, simply use it as a middleware for your express.

app.use(Performance.measure);

For the logger to be able to fully work, you need an extra thing, a route for him to be able to healtcheck your app :

const healthcheck = require('@gferrand/logger-hook').healthcheck;

Then create a route for the logger. E.G:

app.get('/healthcheck/' + $appName + "/" + $appVersion, healthcheck);