MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / log

Method log

src/app/logger/logger.ts:36–68  ·  view source on GitHub ↗
(level: LogLevel, message: string, ...label: LogLabel[])

Source from the content-addressed store, hash-verified

34 }
35
36 log(level: LogLevel, message: string, ...label: LogLabel[]) {
37 const newLabel = buildLabel(this.label, label);
38 if (levelNumber[level] >= levelNumber[this.core.level]) {
39 this.core.writer.write(level, message, newLabel);
40 }
41 let labelJson;
42 try {
43 labelJson = JSON.stringify(newLabel);
44 } catch (e) {
45 labelJson = newLabel;
46 console.error("Logger label JSON stringify error:", e);
47 }
48 if (this.core.consoleLevel !== "none" && levelNumber[level] >= levelNumber[this.core.consoleLevel]) {
49 if (typeof message === "object") {
50 message = JSON.stringify(message);
51 }
52 const msg = `${dayFormat(new Date(), "YYYY-MM-DD HH:mm:ss")} [${level}] ${message}`;
53 switch (level) {
54 case "error":
55 console.error(msg, labelJson);
56 break;
57 case "warn":
58 console.warn(msg, labelJson);
59 break;
60 case "trace":
61 console.info(msg, labelJson);
62 break;
63 default:
64 console.info(msg, labelJson);
65 break;
66 }
67 }
68 }
69
70 with(...label: LogLabel[]) {
71 return new Logger(this.core, ...this.label, ...label);

Callers 15

traceMethod · 0.95
debugMethod · 0.95
infoMethod · 0.95
warnMethod · 0.95
errorMethod · 0.95
gm_add_style.jsFile · 0.80
gm_async.jsFile · 0.80
gm_notification.jsFile · 0.80
onprogressFunction · 0.80
onloadFunction · 0.80
gm_get_resource.jsFile · 0.80

Calls 6

dayFormatFunction · 0.90
buildLabelFunction · 0.85
errorMethod · 0.80
warnMethod · 0.80
writeMethod · 0.65
infoMethod · 0.45

Tested by 8

testFunction · 0.64
testFunction · 0.64
testFunction · 0.64
testFunction · 0.64
testFunction · 0.64
testFunction · 0.64
testFunction · 0.64
autoApprovePermissionsFunction · 0.64