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

@inveris/dev-logger

v2.0.9

Published

A console logger for development purpose with human readable output and easy modifiability.

Downloads

60

Readme

dev-logger

npm version

A ESM console logger for development purpose with human readable output and easy modifiability.

Log levels can be customized, as well as the output (via formatter methods). View examples/ directory.

Please do not use this logger in production mode! For production use pino, winston, bunyan, ...

Install

npm install --save-dev @inveris/dev-logger

Usage

import DevLogger from '@inveris/dev-logger'

const log = new DevLogger(__filename)

log.trace('trace message')
log.debug('debug message')
log.info('info message')
log.success('success message')
log.warn('warn message')
log.error('error message')
log.fatal('fatal message')

const str = 'some value'
log.info('with a string', str)

const obj = {
  value1: 'abc',
  value2: 123
}
log.info('with an object', obj)

const arr = [ 'a', 'b', 4711 ]
log.info('with an array', arr)

Options

const log = new DevLogger(options)

Options could be a string (group) or an object with the following settings:

  • group {string} Name of the group.
    A group is a coherent block of messages that belong together.
    Simpelst usage is setting the current filename.

    group: __filename
  • name {string} An identifier at each line.
    E.g. the application name from package.json could be used.

  • logLevel {number|string} The level from where the output is visible.

  • upperCaseLevelName {boolean} Should the level name displayd in upper case. Default true.

  • padStartLevelName {boolean} Should the level name padded before. Default false.

  • padEndLevelName {boolean} Should the level name padded after. Default false.

  • withDate {boolean} Should the date be visible. Default false.

  • withGroup {boolean} Should the group be visible. Default true.

  • withName {boolean} Should the name be visible. Default true.

  • colors {object} Colors of the output.
    View index.js defaultColors

    colors: {
      trace: 'green',
      info: 'blue'
    }
  • levels {object} List of log methods.
    View index.js defaultLevels

    levels: {
      10: 'debug',
      20: 'info',
      30: 'warn warning',
      40: 'error'
    }

    In this example, we had only debug, info, warn, warning and error methods.
    The first string is the prefix, that is visible on output, e. g. WARN message will be displayed with log.warn('message') or log.warning('message')

Methods

  • setColors(colors)

  • setGroup(group)

  • setName(name)

  • setLevels(levels)

  • setLogLevel(level)

    • level {number|string} The level from where the output is visible.

Default Log-Levels

  • trace
  • debug
  • info
  • success
  • warn / warning
  • error
  • fatal

Custom Log-Levels

import DevLogger from '@inveris/dev-logger'

const log = new DevLogger({
  levels: {
    100: 'basic',
    200: 'normal',
    300: 'extended'
  },
  colors: {
    basic: 'grey',
    normal: 'green',
    extended: 'yellow'
  }
})

log.basic('basic message')
log.normal('normal message')
log.extended('extended message')

Custom formatter

View examples/custom-formatter.js.

Examples

More examples in examples/ directory.

Example:

import DevLogger from '@inveris/dev-logger'

const log = new DevLogger('some id')

log.setLogLevel('trace')

log.trace('trace message')
log.debug('debug message')
log.info('info message')
log.success('success message')
log.warn('warn message')
log.error('error message')
log.fatal('fatal message')