This package has been deprecated

Author message:

vibrato-logger is deprecated, use @alexistessier/report module instead

vibrato-logger

1.1.3 • Public • Published

Vibrato Logger

Project Status : deprecated

This module is currently deprecated. Use the @alexistessier/report module instead. It's fully tested, got a nicer API (in my opinion) and is in many ways more modular.

About

Vibrato Logger is a tiny logger utility. Very basic by himself, it just semantically colors your log messages in console. It's however modular to allow you to do more complex stuff (like saving messages in a file).

Install

npm install vibrato-logger

How to use

Not very complicated :

var log = require('vibrato-logger');

//Five types of message
log.success("Hello world !!!")
log.notice("Hello world !!!")
log.warning("Hello world !!!")
log.issue("Hello world !!!")
log.debug("Hello world !!!")

Even if you can use it like in previous example, it's preferable to instantiate a custom Logger then use it like this (especialy when you define custom message type or custom callback) :

var Logger = require('vibrato-logger');

var log = new Logger({showWarning : false})

log.warning("Hello world !!!")//log nothing
log.issue("Hello world !!!")

You can add a custom callback and change the default color for each message type when instantiating or after :

var Logger = require('vibrato-logger');

var log = new Logger({
	showWarning : false,
	issueCallback : function(message){
		//do what you want with the issue message
	}
});

log.showIssue = false;
log.successColor = 'cyan';
log.successCallback = function (message){
	//do what you want with the success message
};

Available colors are red, green, blue, yellow, purple and cyan... but the defaults are good i think =)

You also can add custom message type to a logger

var Logger = require('vibrato-logger');

var log = new Logger();

log.addMessageType('my message type', {
	show : true,
	callback : function(message){
		//do what you want with the message
	},
	color : 'cyan'
})

log.myMessageType('Hello world !!!');

The method addMessageType returns an object containing the names of created method and properties (or false if the type wasn't added) :

var created = log.addMessageType('my custom type message');
//created.methodName contains "myCustomTypeMessage"
//created.showPropertyName contains "showMyCustomTypeMessage"
//created.colorPropertyName contains "myCustomTypeMessageColor"
//created.callbackPropertyName contains "myCustomTypeMessageCallback"

Dependents (0)

Package Sidebar

Install

npm i vibrato-logger

Weekly Downloads

1

Version

1.1.3

License

MIT

Last publish

Collaborators

  • alexistessier