1.1.0 • Published 8 years ago

nodemsg v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

nodemsg

Super simple message logger for Node.js.

Build Status

Usage

Install from npm repository:

npm install --save nodemsg

Import nodemsg module:

var logger = require('nodemsg'); // name it as you like

Logs whatever you want, with 5 different renderings:

logger.log('Simple log message');
logger.info('Info message');
logger.success('Urrah!');
logger.warn('Achtung!');
logger.error('Oh, no!');

default-use

The methods act like console.log, so you can pass as many parameters you want:

logger.log('I', 'am', 'a', 'simple', 'logger');

multiple-params

The methods are all chainable; so you can write the previous line as:

logger.log('Simple log message')
      .info('Info message')
      .success('Urrah!')
      .warn('Achtung!')
      .error('Oh, no!');

chained

Configuration

You can override defaults configuration passing a configuration object to config() method before using the module:

var logger = require('nodemsg');
logger.config({ ... }); // Your configuration here

...

logger.log('Log stuff with your configuration');
logger.info('Configuration also apply on this message');

The config() method is a kind of getter/setter factory: if you pass an object as parameter, this will be merged with default; otherwise, if you call the method without parameter it will get the current configuration.

Defaults

  • silent (default: false): when true it doesn't log anything in the console;
  • before (default: '>'): string prepended before logged messages;
  • after (default: ''): string appended after logged messages.

Contribution

In order to ensure consistency when edit/build/publish the module, there are some "tricks" which play under the hood:

  • a pretest npm script runs eslint before the tests;
  • a prepublish npm script runs tests before publishing to npm repository.

Tests are made with fantastic, noiseless, TAPE module and rendered piping the stdout into tape-spec module.

This project is developed using Git flow model.

There also is an integration with Travis CI.

Fork the project, edit or use it as you like, make some pull requests to enhance the module: it's nice to be "open".

1.1.0

8 years ago

1.0.0

8 years ago

0.1.7

9 years ago

0.1.5

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago