forked from dbankier/TiShadow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.js
More file actions
33 lines (30 loc) · 643 Bytes
/
logger.js
File metadata and controls
33 lines (30 loc) · 643 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var config = require("./bin/support/config");
require('colors');
color = {
DEBUG: 'blue',
WARN: 'yellow',
REPL: 'grey',
TRACE: 'grey',
ERROR: 'red',
FAIL: 'red',
PASS: 'green'
};
exports.log = function(level, name, msg) {
var msg = "[" + level + "] "
+ (name ? "[" + name + "] ": "")
+ msg;
if (color[level]) {
msg = msg[color[level]];
};
if (config.isREPL) {
process.stdout.write("\r" + msg + "\n> ");
}else {
console.log(msg);
}
}
var levels = ['info','debug','error'];
levels.forEach(function(level) {
exports[level] = function(msg) {
exports.log(level.toUpperCase(),null,msg);
}
});