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

handy-logger

v1.1.3

Published

An easy log handler for Node.js applications

Readme

Handy Logger

Version Build Status Downloads License Known Vulnerabilities

An easy log handler for Node.js application which is built on top of popular logger library winston.

Installation

npm i handy-logger

Get started

Import library

import { HandyLogger, HandyLoggerBase } from 'handy-logger';

HandyLogger

HandyLogger class creates a new logger instance with default or custom configuration.

Create logger with default configuration

const HandyLogger = new HandyLogger();

or with custom configuration

const myLogger = new HandyLogger(opts);

opts config has following properties -

| Option | Type | Default | Description | |---------------------------|--------------------------------------------------------------------------------|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | title | string | undefined | Application title can be provided which will be prefixed (or customized using logDataStringCustomFormat method) in log messages. | | level | LogLevels | string | silly | Log level depending which different kind of log will be written. Read more here. | | exitOnError | boolean | true | If false, handled exceptions will not cause process.exit. Read more here. | | transports | HandyLoggerTransport | {console: [{}]} | A transport is essentially a storage device for your logs. Like winston, handy-logger accepts multiple transports such as console, file etc. Read more here. | | timeStampFormat | (string | (() => string)) | undefined | Custom timestamp format. It can be a string accepted by fetcha module or a method that returns formatted date. | | logDataStringCustomFormat | ((timestamp: string, level: string, title: string, message: string) => string) | undefined | Custom log message format. You can pass a method with timestamp, level, title and message and return a formatted string as you want. |

Transport options (HandyLoggerTransport) are as follows -

  • file Array<FileTransportOptions> - Winston file transport options for logging in files.
  • rotate Array<DailyRotateFileTransportOptions> - Winston daily rotate file transport options for logging in file with rotational logics.
  • console Array<ConsoleTransportOptions> - Winston console transport options for logging in console.
  • http Array<HttpTransportOptions> - Winston http transport options for logging via HTTP.
  • stream Array<StreamTransportOptions> - Winston stream transport options for logging via stream.

HandyLoggerBase

This can be used to set type of the logger when we are calling getLogger(). The type actually refers to winston.logger, so you should be able to access all methods that winston.logger provides.


How to use

import { HandyLogger, HandyLoggerBase, LogLevels } from 'handy-logger';

const loggerObj: HandyLogger = new HandyLogger({
  title: 'My Awesome App',
  level: LogLevels.Info,
  transports: {
    console: [
      {
        handleExceptions: false,
      },
    ],
    file: [
      {
        filename: 'app-error.log',
        level: LogLevels.Error,
      },
      {
        filename: 'app-warning.log',
        level: LogLevels.Warn,
      },
    ],
  },
  timeStampFormat: () => {
    return new Date().toUTCString();
  },
  logDataStringCustomFormat: (ts, lv, title, msg) => {
    return `APP: ${title} :: ${ts} :: [${lv}] :: ${msg}`;
  },
});
const logger: HandyLoggerBase = loggerObj.getLogger();

logger.info('sunny day');
logger.warn('foo bar');
logger.error('err message');

This will log

APP: My Awesome App :: Wed, 05 Feb 2020 15:38:08 GMT :: [info] :: 	sunny day
APP: My Awesome App :: Wed, 05 Feb 2020 15:38:08 GMT :: [warn] :: 	foo bar
APP: My Awesome App :: Wed, 05 Feb 2020 15:38:08 GMT :: [error] :: 	err message

Todos

  • Add custom log levels
  • Add colorize option

License

MIT