Logger

parent f63eae90
/**
* Created by danilaeremin on 28.07.16.
*/
'use strict';
var logger = {
debug : function (string) {
if (this._level >= this.DEBUG)
console.log(this._prefix + '\033[34m Debug: \033[30m' + string);
},
info : function (string) {
if (this._level >= this.INFO)
console.log(this._prefix + '\033[32m Info: \033[30m' + string);
},
warning : function (string) {
if (this._level >= this.WARNING)
console.log(this._prefix + '\033[33m Warning: \033[30m' + string);
},
error : function (string) {
if (this._level >= this.ERROR)
console.log(this._prefix + '\033[31m Error: \033[30m' + string);
},
fatal : function (string) {
if (this._level >= this.FATAL)
console.log(this._prefix + '\033[35m Fatal: \033[30m' + string);
},
DEBUG : 4,
INFO : 3,
WARNING : 2,
ERROR : 1,
FATAL : 0,
_level : this.WARNING,
_prefix : '',
setLogLevel : function (level) {
this._level = level;
},
addPrefix : function (prefix) {
this._prefix = prefix + ':';
}
};
module.exports = logger;
\ No newline at end of file
{
"name": "nodejs-logger",
"version": "1.0.0",
"description": "Logger for mirera node-js server",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://git.niisi.ru/mirera/nodejs-logger.git"
},
"keywords": [
"logger"
],
"author": "Danila Eremin",
"license": "MIT"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment