-
Notifications
You must be signed in to change notification settings - Fork 3
/
logger.js
51 lines (44 loc) · 902 Bytes
/
logger.js
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
/* global process */
var bunyan = require('bunyan');
var sysLog = bunyan.createLogger({
name: 'foo',
streams: [
{
level: 'debug',
stream: process.stdout
}
]
});
// Console.log style formatting.
function formatMessage() {
var formatted = '';
for (var i = 0; i < arguments.length; ++i) {
if (formatted.length > 0) {
formatted += ' ';
}
var arg = arguments[i];
if (typeof arg === 'string') {
formatted += arg;
} else if (typeof arg === 'object') {
formatted += JSON.stringify(arg);
} else {
formatted += arg.toString();
}
}
return formatted;
}
function info() {
sysLog.info(formatMessage(arguments));
}
function warn() {
sysLog.warn(formatMessage(arguments));
}
function error() {
sysLog.error(formatMessage(arguments));
}
module.exports = {
info: info,
warn: warn,
error: error,
sysLog: sysLog
};