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

pince

v0.0.9

Published

A logger for node inspired by log4j and commons-logging.

Downloads

32

Readme

Pince

Pince is a lightweight logger that combines some of the best properties of log4j and node. It's equally usable in Node, (most) browsers, and Meteor (client and server).

It was developed for MadEye.

Features:

  • Log levels: error, warn, info, debug, trace
  • Dynamically change the log level on the client.
  • Change the log level with no code changes on the server.
  • Logging is very lightweight when there's nothing listening to it.
  • Each logger has a name -- you can set levels individually by name!
  • Names can be heirarchally namespaced by separating them with ':'s, like myLibrary:aModule:thisObject.
  • Set log levels by any level of the namespace hierarcy!

Installation (Node.js)

To install, npm install pince.

In any file you wish to make a logger, require it via Logger = require('pince');

Installation (Meteor)

To install, just meteor add jag:pince. The global Logger symbol will be there waiting for you.

By default, on the server Meteor will prepend a string to logs that includes a timestamp (amongst other things). To silence Meteor's prefix, run meteor with the --raw-logs flag: meteor --raw-logs.

Usage

Set the log level:

//Default is info
Logger.setLevel('trace');

Make a new logger:

var log = new Logger('router');
log.info("Routing.");
//2013-10-31 11:29:36.097 info:  [router]  Routing.
log.trace("Setting up routes...");
//2013-10-31 11:29:36.101 trace:  [router]  Setting up routes...

Set individual levels:

Logger.setLevel('info');
Logger.setLevel('controller', 'trace');
var routerLog = new Logger('router');
var controllerLog = new Logger('controller');

routerLog.trace("Can't hear me!");
//Nothing
controllerLog.trace("Can hear me.");
//2013-10-31 11:31:21.906 trace:  [controller]  Can hear me.

Logger.setLevels({router:'debug', controller:'warn'});
routerLog.info("Finally! Someone is listening to me.");
//2013-10-31 11:32:48.374 info:  [router]  Finally! Someone is listening to me.
controllerLog.info("Hello? Hello??");
//Nothing

Hierarchically name and set levels:

var routerLog = new Logger('myPackage:router');
var controllerLog = new Logger('myPackage:controller');
Logger.setLevel('myPackage', 'info');
Logger.setLevel('myPackage:controller', 'debug');

routerLog.info('You can see this.');
routerLog.debug('You cannot see this; myPackage level is set to info.');
controllerLog.debug('You can see this, myPackage:controller level is set to debug.');