-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathloggers.js
75 lines (61 loc) · 1.7 KB
/
loggers.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use strict';
/* eslint-disable no-console */
var dfltConfig = require('../plot_api/plot_config').dfltConfig;
var notifier = require('./notifier');
var loggers = module.exports = {};
/**
* ------------------------------------------
* debugging tools
* ------------------------------------------
*/
loggers.log = function() {
var i;
if(dfltConfig.logging > 1) {
var messages = ['LOG:'];
for(i = 0; i < arguments.length; i++) {
messages.push(arguments[i]);
}
console.trace.apply(console, messages);
}
if(dfltConfig.notifyOnLogging > 1) {
var lines = [];
for(i = 0; i < arguments.length; i++) {
lines.push(arguments[i]);
}
notifier(lines.join('<br>'), 'long');
}
};
loggers.warn = function() {
var i;
if(dfltConfig.logging > 0) {
var messages = ['WARN:'];
for(i = 0; i < arguments.length; i++) {
messages.push(arguments[i]);
}
console.trace.apply(console, messages);
}
if(dfltConfig.notifyOnLogging > 0) {
var lines = [];
for(i = 0; i < arguments.length; i++) {
lines.push(arguments[i]);
}
notifier(lines.join('<br>'), 'stick');
}
};
loggers.error = function() {
var i;
if(dfltConfig.logging > 0) {
var messages = ['ERROR:'];
for(i = 0; i < arguments.length; i++) {
messages.push(arguments[i]);
}
console.error.apply(console, messages);
}
if(dfltConfig.notifyOnLogging > 0) {
var lines = [];
for(i = 0; i < arguments.length; i++) {
lines.push(arguments[i]);
}
notifier(lines.join('<br>'), 'stick');
}
};