Skip to content

Commit 88b46f2

Browse files
🔥 SMALLER AGAIN
1 parent 29f0a8d commit 88b46f2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
module.exports = class Logger {
2-
constructor(settings) {
3-
this.production = settings.production;
2+
constructor(s) {
3+
this.p = s.production;
44
}
55

6-
log(message, type) {
6+
log(m, o) {
77
let t = null
88
let e = false
99
const a ="\x1b["
1010

11-
if (type === "DEBUG") { if (this.production) return; t = `${a}95mDEBUG${a}0m ` }
12-
if (type === "SUCCESS") t = `${a}92mSUCCESS${a}0m`
13-
if (type === "INFO") t = `${a}94mINFO${a}0m `
14-
if (type === "WARN") t = `${a}93mWARN${a}0m `
15-
if (type === "ERROR") { t = `${a}41mERROR${a}0m `; e = true }
16-
if (type === "FATAL") { t = `${a}101mFATAL${a}0m `; e = true }
11+
if (o === "DEBUG") { if (this.p) return; t = `${a}95mDEBUG${a}0m ` }
12+
if (o === "SUCCESS") t = `${a}92mSUCCESS${a}0m`
13+
if (o === "INFO") t = `${a}94mINFO${a}0m `
14+
if (o === "WARN") t = `${a}93mWARN${a}0m `
15+
if (o === "ERROR") { t = `${a}91mERROR${a}0m `; e = true }
16+
if (o === "FATAL") { t = `${a}101mFATAL${a}0m `; e = true }
1717

1818
const r = (new Error()).stack.split('\n')[3].split('(')[1].split(')')[0];
1919
const d = new Date();
20-
const p = `${a}2m[${d.toISOString().replace(/T/, ' ').replace(/Z/, '')}]${a}0m ${t} ${a}2m[${r.substr(0, r.lastIndexOf(":"))}]${a}0m ${message}\n`
20+
const p = `${a}2m[${d.toISOString().replace(/T/, ' ').replace(/Z/, '')}]${a}0m ${t} ${a}2m[${r.substr(0, r.lastIndexOf(":"))}]${a}0m ${m}\n`
2121

2222
if (e) process.stderr.write(p)
2323
else process.stdout.write(p)

0 commit comments

Comments
 (0)