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

solive-winston-logger

v2.0.0

Published

handle logs for solive projects

Readme

SOLIVE-WINSTON-LOGGER

A winston logger that emit logs

USAGE

createLogger

  • options
    • env [String] - Should looks like 'production' or 'development'
    • onNewLog [Function] - The function you want to call on each log
  • RETURNS Logger

It is recommended to not run this operation more than once per instance. Meaning that you can setup your logger once, exporting it and using it everywhere without having to set it up again.

Example:

const logger = createLogger({
    env: 'production',
    onNewLog: (log) => http.post('http://my-log-manager.com', { data: log })
});

Logger

Catch all logs

You can catch all logs that you want to display in order to send them somewhere else Example:

const logger = createLogger({
    env: process.env.NODE_ENV || 'production',
    onNewLog: (log) => {
        // log = a log you've just send to the logger
        // Here you can emit the log wherever you want
        // using http, sockets, amqp...
        // In our case, let's use http since it's
        // the easiest example.
        http.post(
            'http://my-log-manager.com',
            { data: log },
        )
            .then(() => {
                // Here we've send the log somewhere else
            })
    }
})

This works even on sub-instance of a logger (Logger::create). You don't have to setup the onNewLog callback on each sub-instance

Logger::create

You can create a new instance of the logger using create with pre-filled fields

  • fields [Object] (tag|action|details) Example:
const logger = createLogger({ env: process.env.NODE_ENV || 'production' })
const myMovieLogger = logger.create({ tag: 'movie' })

const create = (name, year) => {
    const movieCreationLogger = myMovieLogger.create({ action: 'create' })
    // ...
    // do movie stuff
    if (err) {
        movieCreationLogger.error('An error occurred', {
            details: {
                stack: err.stack,
                route: '/movies',
                name: err.name,
                status: 500,
            },
        })
        // An error occurred {
        //  date: '2018-07-31T16:54:02.668Z',
        //  tag: 'movie',
        //  action: 'create',
        //  details: {
        //   stack: {...},
        //   route: '/movie',
        //   name: 'Error name',
        //   status: 500 }
        //  }
    } else {
        movieCreationLogger.info('Movie saved')
        // Movie saved {
        //  tag: 'movie',
        //  action: 'create',
        //  date: '2018-07-31T16:54:02.668Z' }
    }
}

Logger::info

Informative message are usually used for reporting significant application progress and stages.

  • message [String]
  • more [Object]
    • tag [String]
    • action [String] Example:
const logger = createLogger({ env: 'production' });

logger.info('let\'s log an info', { tag: 'a simple tag', action: 'a simple action' });

You can always provide details, it's just optional in case you are using on of [trace, info, debug]

Logger::trace

...

  • message [String] Example:
const logger = createLogger({ env: 'production' });

logger.trace('let\'s log a trace');

Logger::debug

Used for debugging messages with extended information about application processing.

  • message [String]
  • more [Object]
    • tag [String]
    • action [String] Example:
const logger = createLogger({ env: 'production' });

logger.debug('let\'s log a debug', { tag: 'a simple tag', action: 'a simple action' });

Logger::warn

Such messages are reported when something unusual happened that is not critical to process the current operation, but it would be useful to review this situation to decide if it should be resolved.

  • message [String]
  • more [Object]
    • tag [String]
    • action [String]
    • details [Any] Example:
const logger = createLogger({ env: 'production' });

logger.warn('let\'s log a warn', {
    tag: 'a simple tag',
    action: 'a simple action',
    details: { route: '/a/simple/route' }
});

Logger::error

A serious problem occurred while processing the current operation.

  • message [String]
  • more [Object]
    • tag [String]
    • action [String]
    • details [Object] Example:
const logger = createLogger({ env: 'production' });

logger.error('let\'s log an error', {
    tag: 'a simple tag',
    action: 'a simple action',
    details: {
        route: '/a/simple/route',
        name: 'my_error_name',
        status: 404,
        stack: new Error('Content Not Found').stack,
    },
});

Logger::fatal

The application is in a critical state and cannot proceed with the execution of the current operation. In this case, the application usually reports and terminates.

  • message [String]
  • more [String]
    • tag [Object]
    • action [Object]
    • details [Object] Example:
const logger = createLogger({ env: 'production' });

logger.fatal('let\'s log a fatal error', {
    tag: 'a simple tag',
    action: 'a simple action',
    details: {
        route: '/a/simple/route',
        name: 'my_error_name',
        status: 404,
        stack: new Error('Content Not Found').stack,
    }
});