Skip to content

Commit 0e79fc3

Browse files
⚡️ SMALLER
1 parent fae5424 commit 0e79fc3

File tree

4 files changed

+43
-40
lines changed

4 files changed

+43
-40
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
dist/
22
tests/
3-
node_modules/
3+
node_modules/
4+
Simpllogtest.js

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ type types = "DEBUG" | "SUCCESS" | "INFO" | "WARN" | "ERROR" | "FATAL";
44
declare class Logger {
55
constructor(settings: { production: boolean; });
66
production: boolean;
7-
log(message: string, type: types): void;
8-
}
7+
log(message: string | undefined | null, type: types): void;
8+
}

index.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@ module.exports = class Logger {
44
}
55

66
log(message, type) {
7-
let type2 = null
8-
let iserr = false
7+
let t = null
8+
let e = false
9+
const a ="\x1b["
910

10-
if (type === "DEBUG") type2 = "\x1b[95mDEBUG\x1b[0m "
11-
if (type === "SUCCESS") type2 = "\x1b[92mSUCCESS\x1b[0m"
12-
if (type === "INFO") type2 = "\x1b[94mINFO\x1b[0m "
13-
if (type === "WARN") type2 = "\x1b[93mWARN\x1b[0m "
14-
if (type === "ERROR") { type2 = "\x1b[41mERROR\x1b[0m "; iserr = true }
15-
if (type === "FATAL") { type2 = "\x1b[101mFATAL\x1b[0m "; iserr = true }
11+
if (type === "DEBUG") t = `${a}95mDEBUG${a}0m `
12+
if (type === "DEBUG" && this.production) return
13+
if (type === "SUCCESS") t = `${a}92mSUCCESS${a}0m`
14+
if (type === "INFO") t = `${a}94mINFO${a}0m `
15+
if (type === "WARN") t = `${a}93mWARN${a}0m `
16+
if (type === "ERROR") { t = `${a}41mERROR${a}0m `; e = true }
17+
if (type === "FATAL") { t = `${a}101mFATAL${a}0m `; e = true }
1618

17-
const ret = (new Error()).stack.split('\n')[3].split('(')[1].split(')')[0];
18-
const date = new Date();
19-
const printstr = `\x1b[2m[${date.getFullYear()}-${date.getMonth()}-${date.getDay()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}]\x1b[0m ${type2} \x1b[2m[${ret.substr(0, ret.lastIndexOf(":"))}]\x1b[0m ${message}\n`
19+
const r = (new Error()).stack.split('\n')[3].split('(')[1].split(')')[0];
20+
const d = new Date();
21+
const p = `${a}2m[${d.getFullYear()}-${d.getMonth()}-${d.getDay()} ${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${d.getMilliseconds()}]${a}0m ${t} ${a}2m[${r.substr(0, r.lastIndexOf(":"))}]${a}0m ${message}\n`
2022

21-
if (iserr) process.stderr.write(printstr)
22-
else process.stdout.write(printstr)
23+
if (e) process.stderr.write(p)
24+
else process.stdout.write(p)
2325
}
2426
}

package.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
{
2-
"name": "simpllog",
3-
"version": "1.1.1",
4-
"description": "📝 A simple and VERY lightweight logger for Typescript and Javascript.",
5-
"main": "./index.js",
6-
"repository": {
7-
"type": "git",
8-
"url": "git+https://github.com/CallMeEchoCodes/simpllog.git"
9-
},
10-
"keywords": [
11-
"logger",
12-
"log",
13-
"console",
14-
"typescript",
15-
"javascript",
16-
"simple",
17-
"lightweight",
18-
"simple-logger",
19-
"simple-console",
20-
"simple-log",
21-
"simple-logger",
22-
"simpllog"
23-
],
24-
"author": "CallMeEcho",
25-
"license": "MIT"
2+
"name": "simpllog",
3+
"version": "1.1.3",
4+
"description": "📝 A simple and VERY lightweight logger for Typescript and Javascript.",
5+
"main": "./index.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/CallMeEchoCodes/simpllog.git"
9+
},
10+
"keywords": [
11+
"logger",
12+
"log",
13+
"console",
14+
"typescript",
15+
"javascript",
16+
"simple",
17+
"lightweight",
18+
"simple-logger",
19+
"simple-console",
20+
"simple-log",
21+
"simple-logger",
22+
"simpllog"
23+
],
24+
"author": "CallMeEcho",
25+
"license": "MIT"
2626
}

0 commit comments

Comments
 (0)