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

loggerw

v1.0.3

Published

Advanced logger for JS applications

Readme

LoggerW

LoggerW is an advanced library to make logs on your application. It is written in TypeScript and its compatible with almost every project built in node.js and built-in middleware for express.js

Features

  • Log on console and text file
  • Native express.js middleware
  • Simple way to make logs professional looking logs inside your application
  • Information about what file called the logger
  • KeyName and KeyValue fields for tracking

Installation

Install LoggerW NPM package

npm install loggerw

Then create your settings file based on this example.

{
    "LoggerW" : {
        "logFile":{
            "location": "/logs",
            "fileNameFormat":"[TS].log",
            "fileNameTimeStampFormat":"YYYYMMDD",
            "enableOriginFileLog": true,
            "enableFileLog": true,
            "enableConsoleLog": true
        },
        "express": {
            "enableRequestLog": true,
            "enableResponseLog": true
        },
        "ids":{
            "request": {
                "enable": true,
                "header": "x-request"
            },
            "correlation": {
                "enable": true,
                "header": "x-request"
            }
        }
    }
}

Learn more about this file on Settings File chapter bellow.

Usage

Express Middleware

To enable the middleware you just need to import the library and add it to your application

import {expressLogger} from 'loggerw'
import express from 'express'
const app = express()
app.use(expressLogger.expressMiddleware)

Combined with the default settings this will log all request and corresponding response of your application.

[2021-02-21T17:04:36+00:00] [INFO] [SERVICE_START] "::1 http GET / {\n \"query\": {},\n \"headers\": {\n  \"user-agent\": \"PostmanRuntime/7.26.10\",\n  \"accept\": \"*/*\",\n  \"postman-token\": \"c816ae78-3240-47d5-ba85-ffe23632ca2b\",\n  \"host\": \"localhost:3000\",\n  \"accept-encoding\": \"gzip, deflate, br\",\n  \"connection\": \"keep-alive\"\n }\n}"
...
[2021-02-21T17:04:36+00:00] [INFO] [SERVICE_END] "::1 http GET / 200 {\n \"header\": \"{\\\"x-powered-by\\\":\\\"Express\\\",\\\"x-request\\\":\\\"d0157889-8633-47b5-80a2-2e8573adf535\\\"}\",\n \"body\": \"\\\"Hello World!\\\"\"\n}"

This middleware make 2 logs: Service Start and Service End

  • Service Start: Log the information that reach the application such as IP address, protocol, HTTP verb, endpoint, query params, request headers and body.
  • Service End: Log the information that reach the application such as IP address, protocol, HTTP verb, endpoint, response status code, headers and body.

General use logger

Besides express, you can create your own logs based on generic logs and adapters

Generic logs

The method to create a generic log is

log(Log Level, Log Message, [KeyName, [KeyValue]])

The possible values for Log Level are

  • INFO
  • DEBUG
  • TRACE
  • WARNING
  • ERROR

And they are available from logLevel property.

To use this you need to import the default module, instanciaste it and then create your log

import loggerw from 'loggerw'
const logger = new loggerw()
logger.log(log.logLevel.info, "Making a log on / endpoint")

This will generate the following result

[2021-02-21T17:04:36+00:00] [INFO] [\index.ts]  "Logging some information on / endpoint"

If you send two more string values, they will assume the values of KeyName and KeyValue e.g The following code

log.log(log.logLevel.info, "Making a log on / endpoint", "userId", "1000")

Will generate the following log

[2021-02-21T17:04:36+00:00] [INFO] [\index.ts] [keyName:userId keyValue:1000] "Logging some information on / endpoint"
Adapters

The method to create a generic log is

adapter(Adapter Type, Log Message, [KeyName, [KeyValue]])

The possible values for Adapter Type are

  • ADAPTER_START
  • ADAPTER_END
  • ADAPTER_ERROR
  • SERVICE_START
  • SERVICE_ERROR

And they are available from adapters property.

To use this you need to import the default module, instanciaste it and then create your log

import loggerw from 'loggerw'
const logger = new loggerw()
logger.adapter(log.adapters.start, "127.0.0.1 HTTP GET /page {query: {}, header:{}, body:{}}")

This will generate the following result

[2021-02-21T17:04:36+00:00] [ADAPTER_START]  "127.0.0.1 HTTP GET /page {query: {}, header:{}, body:{}}"

The rules for keyName and keyValue are the same as log() method.

This function is used on express.js middleware to provide Service Start/End log messages

Settings File

Settings file is used to provide some customization on the logger on your application. This uses the module node-config-ts. You can add more configurations to this file besides, you just need to guarantee the loggerW settings are in place.

| Field | Description | Possible Values | |-----------------------------|----------------------------------------|---------------------| | LoggerW | Root element | | | logFile | Log file related settings | | | location | Location from your project root | Any valid location | | fileNameFormat | Log filename template | Any valid file name | | fileNameTimeStampFormat | Timestamp on log filename | Any valid format allowed for moment module. This value will replace [TS] on your filename| | enableOriginFileLog | Used to show what file called logger | true/false | | enableFileLog | Enable writing the logs on file | true/false | | enableConsoleLog | Enable writing the logs on console | true/false | | express | Express.JS middleware related settings | | | enableRequestLog | Enable service start log | true/false | | enableResponseLog | Enable service end log | true/false | | ids | Ids related settings | | | request id | Request id related settings | | | enable | Enable request id management | | | header | Header name used for request id | | | correlation id | Correlation id related settings | | | enable | Enable correlation id management | | | header | Header name used for correlation id | |