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

project-logger

v4.4.3

Published

Logger with basic capabilities for small projects

Downloads

33

Readme

project-logger

project-logger is simple logging utility for textual application logs. It has simple log-flooding protection, ability to send messages about errors to master process in the cluster and proxy to debug module.

##Example

var logger = require('project-logger')('test');

logger.info('Object is now: ', obj);
// 24 Feb 2016 16:40:14 - [server] - 24010 - INFO:  Object is now:   {"hello":"world"}

logger.error(new Error('Initialization error'));
// 24 Feb 2016 16:40:14 - [server] - 24010 - ERROR:  Error: Initialization error
//  at Object.<anonymous> (../example.js:3:14)
//  ...

##How to use ###Configuration All loggers share same configuration. It can be set on factory-method. All options with defaults explained below.

// values below are default ones
var Logger = require('project-logger').configure({
  ns: undefined,   // prefix for all logger names
  level: 'info',   // log level, can be 'error', 'warning' and 'info'
  console: true,   // whether to send messages to console
  cluster: false,  // whether to send messages to master process
  colors: true,    // whether console output should be colored,
  debug:           // namespaces to enable for debug, see https://www.npmjs.com/package/debug for more info, usual DEBUG env variable works as well
  repeat: 1000     // time in ms, when identical messages stacked
  simple-prefix: false // whether timestamp and process id should omitted from prefix
});

By default loggers try to stack identical messages repeated freqently in one. So if you log same message 100 times in a row in less than a second it will show up in logs only once and then number of times it was repeated (just like syslog). If you don't like it, set repeat to 0.

####logger.error(...), logger.warning(...), logger.info(...) Logs objects and messages with appropriate level. Accepts any number of arguments, that will be concateneted in one message. Argument can be a string, an object or an Error instance, which will result in stack trace logged.

####logger.debug(...) Logs debug message with debug module

####logger.progress(...) Logs info message to console via process.stdout.write(). This do not add new line at the end of the message. Starts progress mode.

####logger.progressReplace(...) Same as logger.progress(...) but also clears all input from current progress session from console output.

####logger.progressEnd(...) Same as logger.progress(...) but ends current progress session and adds new line at the end.

##Contributing Found a bug, have a feature proposal or want to add a pull request? All are welcome. Just go to issues and write it down.