MCPcopy
hub / github.com/orion-lib/OrionTV / formatMessage

Method formatMessage

utils/Logger.ts:33–53  ·  view source on GitHub ↗

* 格式化日志输出

(level: string, tag: string | undefined, message: any, ...args: any[])

Source from the content-addressed store, hash-verified

31 * 格式化日志输出
32 */
33 private formatMessage(level: string, tag: string | undefined, message: any, ...args: any[]): void {
34 if (!__DEV__) return;
35
36 const timestamp = new Date().toISOString().substr(11, 12);
37 const prefix = tag ? `[${timestamp}][${level}][${tag}]` : `[${timestamp}][${level}]`;
38
39 switch (level) {
40 case 'DEBUG':
41 console.log(prefix, message, ...args);
42 break;
43 case 'INFO':
44 console.info(prefix, message, ...args);
45 break;
46 case 'WARN':
47 console.warn(prefix, message, ...args);
48 break;
49 case 'ERROR':
50 console.error(prefix, message, ...args);
51 break;
52 }
53 }
54
55 /**
56 * 调试级别日志

Callers 4

debugMethod · 0.95
infoMethod · 0.95
warnMethod · 0.95
errorMethod · 0.95

Calls 3

infoMethod · 0.80
warnMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected