-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev-log.js
101 lines (90 loc) · 2.44 KB
/
dev-log.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var gutil = require('gulp-util');
module.exports = dev = (function() {
let isDebugMode = false;
let isVerboseMode = false;
let logToFile = false;
const API = {
init: (isDebug, isVerbose, logToFile) => {
return initModule(isDebug, isVerbose, logToFile);
},
log: log,
logverbose: logverbose,
logpackets: logpackets,
logfunction: logfunction,
error: error,
isDebug: () => isDebugMode
};
function initModule(d, v, l) {
isDebugMode = d;
isVerboseMode = v;
logToFile = l;
console.log(`Init module with debug = ${d} and verbose = ${v}`);
if (isDebugMode) {
console.log('Debug mode is Enabled');
console.log('---');
dev.logfunction('(log) magenta is for functions');
dev.logpackets('(log) green is for packets');
dev.logpackets('(log) green is for packets');
if (isVerboseMode) {
dev.logverbose('(dev and verbose) gray for regular parsing data');
}
}
if (logToFile) {
console.log('Logging to file');
} else {
console.log('Not logging to a file');
}
return;
}
function log() {
var args = Array.prototype.slice.call(arguments);
var logArgs = args;
_sendToLogFile(logArgs);
_sendToConsole(logArgs, gutil.colors.white);
}
function logverbose() {
// gray
var args = Array.prototype.slice.call(arguments);
var logArgs = '- '.concat(args);
if (logToFile) {
_sendToLogFile(logArgs);
}
if (isDebugMode && isVerboseMode) {
_sendToConsole(logArgs, gutil.colors.gray);
}
}
function logpackets() {
// green
var args = Array.prototype.slice.call(arguments);
var logArgs = '* '.concat(args);
if (logToFile) {
_sendToLogFile(logArgs);
}
if (isDebugMode) {
_sendToConsole(logArgs, gutil.colors.green);
}
}
function logfunction() {
// magenta
var args = Array.prototype.slice.call(arguments);
var logArgs = '~ '.concat(args);
if (logToFile) {
_sendToLogFile(logArgs);
}
if (isDebugMode) {
_sendToConsole(logArgs, gutil.colors.magenta);
}
}
function error() {
// red
var args = Array.prototype.slice.call(arguments);
var logArgs = 'ERROR! '.concat(args);
_sendToLogFile(logArgs);
_sendToConsole(logArgs, gutil.colors.red);
}
function _sendToLogFile(logArgs) {}
function _sendToConsole(logArgs, color = gutil.colors.white) {
gutil.log(color(logArgs));
}
return API;
})();