Micro server-side logger for nodejs. ~50 sloc
JavaScript
Latest commit dda5ab1 Oct 25, 2014 @A Update readme.md
Permalink
Failed to load latest commit information.
test add coverage Sep 30, 2014
.gitignore add coverage Sep 30, 2014
.jshintrc add code Feb 17, 2014
.travis.yml fix coveralls Sep 30, 2014
index.js add coverage Sep 30, 2014
package.json fix coveralls Sep 30, 2014
readme.md Update readme.md Oct 25, 2014

readme.md

Microlog

Build Status Code Climate Coverage Status

NPM

Micro server-side logger for nodejs. ~50 sloc

screenshot

Why to use?

  • Very simle
  • ~50 sloc
  • Support express like formattings
  • Support to add timestamps to logs
  • Support to add filenames to logs
  • Support printf like logging: log.info('%d port', port)
  • Support colorful logs and NOCOLOR env variable that is so useful in some cases
  • Support NOLOG env variable
  • Log methods returns messages to runtime too
  • Very simple

Install

npm i -S microlog

Usage

var log = require('microlog')(Object module, [String format], [Boolean logOnRequire]);
  • module — node.js module link
  • format — express like formatting string
  • logOnRequire — write init messages to logs

Example:

var log = require('microlog')(module);
log.info('Express listen %s host and %d port', config.get('HOST'), config.get('PORT'));
log.error('Get error message: %message', message);
log.debug('Shit! Shit! Shit!11')

Formatings

  • :type — message type: info, debug, error
  • :module – module name if it exists
  • :message — message body

Todo

  1. Log levels
  2. Transports support