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

cp-logger

v0.0.5

Published

A tiny lightweight logger module used by many codeProgressive projects.

Downloads

4

Readme

codeProgressive logo

cp-logger

A tiny lightweight logger module used by many codeProgressive projects. The logger is designed to easily log on different levels such as; 'error' and 'warning'. It also gives the option to write the log to a file in a descent manner. A timestamp will automatically be included for your convenience.

Installation

$ npm install cp-logger

Usage

Instantiate and initialize the logger module.

var log = require( 'cp-logger' ).init( <level> , <options> )

Both parameters are optional.

The level parameter is a number from 0 to 3 defining the maximum level of logs to be shown. This way, when using different environments, you can set the level accordingly. When set to 0, only errors will be shown and when set to 3; all logs will be shown.

The options parameter is optional but when used, should be an object containing overrides to the options which are set by default.

After initializing you can easily log messages using the following methods:

Debug information

Will be used when the log level set equals 3

log.debug( "This is some debug information" );

General information

Will be used when the log level set equals 2 or higher

log.info( "This is some information" );

Warning

Will be used when the log level set equals 1 or higher

log.warning( "This is a warning" );

Error

log.error( "This is an error" );

Example

Here is an example on how to initialize the logger

Options

The options object can override each of the following options;

  • catchAllExceptions : Boolean (default : false)

    • WARNING: Do not use this option! Catch all exceptions which will try to stop the application from crashing. Will likely cause instability as your application will probably not know what to do after triggering an exception.
  • colors : Boolean (default true)

    • Enable or disable colors in the console.
  • sendToScreen : Boolean (default true)

    • Send the logs to the stdout (the console), because maybe you only want to write to a log file and not show them in the console.
  • saveToFile : Boolean (default false)

    • Save all logs to the file specified in the filePath option.
  • filePath : String (default "./app.log")

    • If the saveToFile option is enabled, this is the file which will be written to when logging.

License

GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007