-
Notifications
You must be signed in to change notification settings - Fork 0
/
kloger.js
30 lines (30 loc) · 1.05 KB
/
kloger.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
module.exports = class kLoger {
constructor(setting) {
this.setting = {
info: setting.info,
debug: setting.debug,
error: setting.error,
}
}
info(txt) {
const dt = new Date();
const time = `${dt.getFullYear()}/${dt.getMonth()}/${dt.getDay()}/${dt.getHours()}:${dt.getMinutes()}:${dt.getSeconds()}`
if (this.setting.info) {
console.info(`[${time}][info] ${txt}`);
}
}
debug(txt) {
const dt = new Date();
const time = `${dt.getFullYear()}/${dt.getMonth()}/${dt.getDay()}/${dt.getHours()}:${dt.getMinutes()}:${dt.getSeconds()}`
if (this.setting.debug) {
console.debug(`[${time}][debug] ${txt}`);
}
}
error(txt) {
const dt = new Date();
const time = `${dt.getFullYear()}/${dt.getMonth()}/${dt.getDay()}/${dt.getHours()}:${dt.getMinutes()}:${dt.getSeconds()}`
if (this.setting.error) {
console.error(`[${time}][error] ${txt}`);
}
}
}