Giter Site home page Giter Site logo

nodemsg's Introduction

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".

nodemsg's People

Contributors

stefanomagrassi avatar

Stargazers

 avatar

Watchers

 avatar  avatar

nodemsg's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.