-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlog.js
More file actions
66 lines (60 loc) · 2.17 KB
/
log.js
File metadata and controls
66 lines (60 loc) · 2.17 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Generated by CoffeeScript 1.6.3
(function() {
var debugEnabled, log, util, write,
__slice = [].slice;
util = require('util');
debugEnabled = function() {
return (typeof window !== "undefined" && window !== null ? window.debug : void 0) || (process.env.DEBUG && process.env.DEBUG.toLowerCase() !== "false");
};
write = function(level, message, formatParams) {
if (process.env.DISABLE_LOGGING) {
return;
}
if (formatParams) {
formatParams.unshift(message);
if (process.env.NOLOGPID || (typeof window !== "undefined" && window !== null)) {
return util.log("[" + level + "] " + (util.format.apply(util.format, formatParams)));
} else {
return util.log("[" + process.pid + "] [" + level + "] " + (util.format.apply(util.format, formatParams)));
}
} else {
if (process.env.NOLOGPID || (typeof window !== "undefined" && window !== null)) {
return util.log("[" + level + "] " + message);
} else {
return util.log("[" + process.pid + "] [" + level + "] " + message);
}
}
};
log = {
error: function() {
var message, others;
message = arguments[0], others = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return write("ERROR", message, others);
},
info: function() {
var message, others;
message = arguments[0], others = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return write("INFO", message, others);
},
warn: function() {
var message, others;
message = arguments[0], others = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return write("WARN", message, others);
},
debug: function() {
var message, others;
message = arguments[0], others = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if (debugEnabled()) {
return write("DEBUG", message, others);
}
},
event: function() {
var message, others;
message = arguments[0], others = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if (debugEnabled()) {
return write("EVENT", message, others);
}
}
};
module.exports = log;
}).call(this);