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

ledger

v0.1.0

Published

Event based utility for logging to stdout, file or database.

Downloads

48

Readme

#Ledger Ledger is an event based NodeJS module used for logging events to stdout, files or MongoDB.

Ledger overwrites console.log console.info console.warn and console.error to allow all output to be either colorized or outputted to a file or a MongoDB server.

##Installation:

npm install ledger

##Usage: //this will output to stdout/stderr //ledger.log and MongoDB listening at 127.0.0.1 var ledger = (require('ledger')({ logFile: 'ledger.log', logDb: true, });

ledger.on('log::error', function(time, msg){
    //do something special with errors
});

ledger.on('log::*', function(time, msg){
    //log catchall
});

console.log('log');
console.info('info');
console.warn('warn');
console.error('error');

##Options:

useColor: Boolean //whether to colorize stdout/stderr, Default: true
separator: String //separator used when building messages, Default: ' > '
timeFormatter: Function(date) //function used when formatting Date object to a string, Default: function(date){ return date.toString(); }

logStdout: Boolean //whether or not to print to stdout/stderr, Default: true
logFile: String //file to log all messages to, Default: false
logDb: Boolean //whether or not to log to a MongoDB server, Default: false

dbHost: String //host of MongoDB server, Default: '127.0.0.1'
dbPort: String //port that MongoDB server is listengin on, Default: '27017'
dbName: String //name of MongoDB database, Default: 'ledger'
dbCollection: String //name of collection to store messages in, Default: 'log'
dbUser: String //username to use when connecting to MongoDB server, Default: false
dbPass: String //password used to connect to MongoDB server, Default: false

##Methods:

log(msg) //mapped to console.log
info(msg) //mapped to console.info
warn(msg) //mapped to console.warn
error(msg) //mapped to console.error
now() //get the current time using timeFormatter setting

##Events:

log::log: (time, msg) //event that gets called after a call to console.log
log::info: (time, msg) //event that gets called after a call to console.info
log::warn: (time, msg) //event that gets called after a call to console.warn
log::error: (time, msg) //event that gets called after a call to console.error