Giter VIP home page Giter VIP logo

imed-logger's Introduction

NPM Version Build Status Dependency Status devDependency Status License

imed-logger

A small library providing utility methods to log messages into console.

Installation

npm install imed-logger --save

Usage

const {
	error,
	warn,
	info,
	verbose,
	debug,
	silly,
	assert,
	inspect
} = require('imed-logger'); // => levels: info, debug, warn, error

const {
	error,
	warn
} = require('imed-logger').level('warn'); // => levels: warn, error

To disable a method for a module some function use the silent function, e.g.:

const {
	silent: info,
	debug,
	silent: warn
} = require('imed-logger'); // => will log on debug() but not on info() nor on warn()

info('this message will not be log because silent is used');
debug('this message will be logged as a debug message');
warn('this message will not be log because silent is used');

Levels

Levels order is :

error > warn > info > verbose > debug > silly

Default level is info. You can change level on runtime with:

logger.level('warn'); // => only warn and error will then actually log to console.

or get the current level with:

logger.level(); // => 'warn'

Theme : colors and styles

To change default colors, call setTheme with one or more levels colorization

logger.setTheme({
	error: ["white", "bold", "bgRed"],
	warn: ["yellow", "bold"],
	info: ["cyan", "bold"],
	verbose: ["blue", "bold"],
	debug: "magenta",
	silly: "rainbow"
};

For instance,

logger.setTheme({'silly': ['white', 'bold', 'bgBlue']});
logger.silly("a silly message");

results in :

[silly] 2019-6-20 12:01:04 a silly message

For more information on text and background colors, styles and extras, see https://github.com/Marak/colors.js.

To disable colors you can pass the following arguments in the command line to your application:

node myapp.js --no-color

Tests

npm test

Documentation

npm run docs

will generate the documentation and open its index.html file. It's a shortcut of:

npm run generate-docs
npm run show-docs

If the index.html file does not show in your browser, edit package.json file and see if version number should be updated in scripts["show-docs"], or open file in ./docs/imed-logger/<version>/index.html (e.g. ./docs/imed-logger/0.1.3/index.html).

Contributing

No formal styleguide imposed, just take care to maintain the existing coding style.

  • Add unit tests for any new or changed functionality.
  • Lint and test your code.
  • Take special care to comment your code with JSDoc3, see jsdoc.app.

Release History

  • 0.1.3 minor corrections --Thu Jun 20 14:27:31 CEST 2019

  • 0.1.2 tag correction. --Thu Jun 20 14:06:46 CEST 2019

  • 0.1.1 changed the npm run show-docs command. --Thu Jun 20 13:42:39 CEST 2019

  • 0.1.0 added setTheme function, and 1st commit to github. --Thu Jun 20 12:07:09 CEST 2019

  • 0.0.2 added inspect and assert functions. --Wed Jan 18 2017 10:11:00 GMT+0100 (CET)

  • 0.0.1 Initial release. --Fri May 13 2016 19:52:00 GMT+0200 (CEST)

About me

see www.imed.ch.


© imed.ch - Last modified : Thu Jun 20 11:04:36 CEST 2019

imed-logger's People

Contributors

jguillod avatar

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.