Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sisilicon
GitHub Repository: sisilicon/worldedit-be
Path: blob/master/src/library/utils/contentlog.ts
1784 views
1
/* eslint-disable @typescript-eslint/no-explicit-any */
2
import config from "config.js";
3
4
function date() {
5
return `[${new Date().toLocaleTimeString()}]`;
6
}
7
8
class ContentLog {
9
verbose(...msg: any[]) {
10
console.log("[VERBOSE]", date(), ...msg);
11
}
12
13
log(...msg: any[]) {
14
console.log("[LOG]", date(), ...msg);
15
}
16
17
warn(...msg: any[]) {
18
console.warn("[WARN]", date(), ...msg);
19
}
20
21
error(...msg: any[]) {
22
console.error("[ERROR]", date(), ...msg);
23
if (msg[0]?.stack) console.error(msg[0].stack);
24
}
25
26
debug(...msg: any[]) {
27
if (config.debug) console.log("[DEBUG]", date(), ...msg);
28
}
29
30
stack() {
31
return new Error().stack.split("\n").splice(1).join("\n");
32
}
33
}
34
35
export const contentLog = new ContentLog();
36
37