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 🙏

© 2024 – Pkg Stats / Ryan Hefner

hiplog

v1.0.2

Published

Fancy lightweight logging utility.

Downloads

7

Readme

Fancy lightweight logging utility for Node.js

Latest Stable Version Build Status NPM Downloads dependencies Status Test Coverage API Documentation

Installation

Prerequisites: Node.js 6+, npm 3+.

npm install --save hiplog

Usage

const { Log } = require('hiplog');
const log = new Log({ level: 'debug' });
log.debug('messages to debug an application');
log.info('a purely informational message');
log.notice('a normal but significant condition');
log.warning('warning condition');
log.error('error condition');
log.critical('the system is in critical condition');
log.alert('action must be taken immediately');
log.emergency('system is unusable');

Hiplog levels output

Objects

Objects are automatically stringified using Purdy. Small objects (< 200 characters) are inlined.

log.info('a small object:', { int: 123, bool: true, str: 'Hello' });

Hiplog small objects output

const circular = {};
circular.inner = circular;

log.info('a bigger object', {
  null: null,
  undefined,
  integer: 123,
  boolean: true,
  string: 'Hello',
  funtion: function myFunction() {},
  circular,
  array: ['one', 'two', 'three', 'four'],
});

Hiplog big objects output

Errors

Errors are displayed using jest-message-util (powered by :sparkles: babel-code-frame :sparkles:):

try {
  throw new Error('Error example');
} catch (e) {
  log.error(e);
}

Hiplog errors output

Options

level

  • type: string
  • default value: 'info'

Minimum level to display. All messages below this level will be ignored.

stream

  • type: Steam | function: integer -> Stream
  • default value:
    level => (level <= 4 ? process.stderr : process.stdout)

Stream to write to.

displayTime

  • type: boolean
  • default value: false

Whether to display time information or not. Example:

Hiplog time output

displayTimeFormat

  • type: string
  • default value: 'yyyy-mm-dd HH:MM:ss.l'

Date format to display time in, when displayTime is set to true. See dateformat for possible values.

separator

  • type: string
  • default value: ' • '

Separator between message header and body, and also between time and and label, when displayTime is set to true;

format

  • type: function: string -> string
  • default value: hiplog.format

Message formatter function.

fromEnv

const hiplog = require('hiplog');
const log = hiplog.fromEnv();

fromEnv is a utility function that will create a new instance of Log with options taken from environment variables:

  • NODE_ENV:
    • 'development' (default): displayTime is disabled,
    • 'test': displayTime is disabled, 'level' is set to 'critical',
    • 'production': use default values for each option.
  • LOG: sets level value.
  • LOG_LEVEL: alias for LOG.
  • LOG_TIME: when set to true or 1, enables displayTime.
  • LOG_TIME_FORMAT: sets displayTimeFormat value.

Note: fromEnv accepts an options parameter that allow overriding these defaults. Example:

const hiplog = require('hiplog');
const log = hiplog.fromEnv({ displayTime: false });
// displayTime will be always `false`, disregarding the value of `LOG_TIME`.

Contributing

Please refer to the guidelines for contributing.

devDependencies Status

License

License


Created with npm-package-skeleton.