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

rtp-logger

v4.0.0

Published

Registered traveller programme logger

Downloads

8

Readme

rtp-logger Build Status

Thin wrapper around winston for use in Registered Traveller Programme node.js applications.

Usage

To use the logger simply add rtp-logger to your dependencies in the package.json and then require it in your main javascript file.

The default are as follows: -

  • Console transport logging to stdout and stderr
  • Log level = debug
  • Include timestamps on log entries
  logger.info('message');

To log objects, simply pass an additional parameter to the logging function. This will be Stringified using the util.inspect module

  logger.error('message', {'key': 'value});

Configuration

To configure the logger further you can use the setup() function, passing an object. Below is an example of the options that can be used: -

{
    loglevel: 'info',
    appName: 'MY-APP', // will appear as [MY-APP] in log entries
    transports: {
        console: {
            // any valid winston config options when creating a console transport
            timestamp: false,
            debugStdout: false
        }
    }
}

Run tests

The unit tests are written in mocha and can be run using npm.

npm test

You can also run the tests using grunt. Before running the unit tests it will perform a run jshint and jscs. From the project root, run the following: -

grunt dev

If you would like to watch all javascript files and automatically re-run jshint, jscs and mocha you can use the following: -

grunt watch

File transport

File logging is not currently a requirement as all logs file are created from stdout and stderr and will be for the foreseeable future. However, the code to handle configuration of a file transport was written and is available in the file-transport branch. Should this be required at a later date, it could be merged into the master branch and used.

To configure the logger with a file transport you can use the setup() function, passing an object. Below is an example of the options that can be used: -

{
    logLocation: '/log/test.log'
    transports: {
        file: {
            // any valid winston config options when creating a file transport
            filename: 'some-log-file.log', // this would override logLocation
            timestamp: false,
            maxsize: 128,
            maxFiles: 1
        }
    }
}

The existence of logLocation or transports.file in the config will trigger the addition of a file transport to the logger.

If only logLocation is present then the default config for a file transport will be used, this is as defined here.

{
    filename: // logLocation or 'app.log'
    timestamp: true,
    maxsize: 10240,
    maxFiles: 3
}

The Registered Traveller Programme uses BrowserStack for mobile and desktop testing https://www.browserstack.com/