Micro server-side logger for nodejs. ~50 sloc
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
.jshintrc
.travis.yml
index.js
package.json
readme.md

readme.md

Microlog

Build Status Code Climate Coverage Status

NPM

Micro server-side logger for nodejs. ~50 sloc

screenshpot

Why to use?

  • Very simple
  • ~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