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

snaplog

v0.3.3

Published

A better logger tool than console.log with colors, progress and deep inspection

Downloads

24

Readme

Snaplog

This small tool allow you to enhance your logs in console. Use differents levels of log, create a progress bar, deeply inspect your objects and enhance your errors.

NPM

ng-flat-datepicker screenshot

(Working progress) - only tested on nodejs 5.0 with ES6. I plan to convert in ES5 with Babel and so support older version of nodejs. Please, feel free to contribute.

Todo :

  • support ES5 with Babel
  • unit tests

Install

$ npm install snaplog --save

Usage

// Basic usage
var logger = require('snaplog');

// Set options to the logger
logger.config({}) // optional

// Log in console with differents levels
logger.success('We did it !');
logger.info('Roger that !');
logger.warn('Houston do you copy ??');
logger.error('Houston we have a problem !');
logger.emergency('Mayday Mayday Mayday !');
logger.inspect({we: {find: {the: {black: [{box: '!!!!'}]}}}});

// Create a progressbar
var progress = logger.progress({title: 'From Paris to New York', steps: 4});

setTimeout(nextCall, 1000, 'Roger that !');
setTimeout(nextCall, 3000, 'Houston we have a problem !');
setTimeout(nextCall, 5000, 'Mayday Mayday Mayday !');
setTimeout(nextCall, 7000, 'We did it !');

function nextCall(message) {
	progress.next({description: message});
}

Methods

.config(options) - This method allows you to set up the logger

  • (String) Object
logger.config({
	enabled: true, // toggle the logger
	time: {
		enabled: true, // toggle time display
		format: 'YYYY-MM-DD HH:mm:ss' // set time format
	},
	levels: { // levels settings
		success: {enabled: true, color: 'green'},
		info: {enabled: true, color: 'blue'},
		warn: {enabled: true, color: 'yellow'},
		error: {enabled: true, color: 'red'}
	}
}
  • .success(message) - print success log in terminal with colors

  • .info(message) - print info log in terminal with colors

  • .warn(message) - print warn log in terminal with colors

  • .error(message) - print error log in terminal with colors

  • .emergency(message) - print emergency log in terminal with colors

  • (String) message

logger.success('We did it !');
logger.info('Roger that !');
logger.warn('Houston do you copy ??');
logger.error('Houston we have a problem !');
logger.emergency('Mayday Mayday Mayday !');

.inspect(object, depth) - Deep inspection of an object

  • (String) message
  • (Number) depth
logger.inspect({ we: { find: { the: { black: [ { box: '!!!!'}]}}}});

Progress bar

.progress(options) - Instanciate a new progress bar

  • (Number) options.steps [required - set the total steps for the progression]
  • (String) options.title [optional - set the log's title]
var progress = logger.progress({title: 'From Paris to New York', steps: 4});

progress.next(options) - Push the next step

  • (String) options.description [optional - description of the step - default:1]
  • (String) options.steps [optional - number of steps to push - default:'']
progress.next({description: 'Roger that !'});

License: MIT

Author: Alexandre Da Costa