MCPcopy Create free account
hub / github.com/Rfym21/Qwen2API / constructor

Method constructor

src/utils/logger.js:9–83  ·  view source on GitHub ↗
(options = {})

Source from the content-addressed store, hash-verified

7 * 统一管理项目中的日志输出,支持分级打印、时间戳、Emoji标签等功能
8 */
9class Logger {
10 constructor(options = {}) {
11 this.options = {
12 // 日志级别: DEBUG < INFO < WARN < ERROR
13 level: options.level || 'INFO',
14 // 是否启用文件日志
15 enableFileLog: options.enableFileLog || false,
16 // 日志文件路径
17 logDir: options.logDir || resolveRuntimePath('logs'),
18 // 日志文件名格式
19 logFileName: options.logFileName || 'app.log',
20 // 是否显示时间戳
21 showTimestamp: options.showTimestamp !== false,
22 // 是否显示日志级别
23 showLevel: options.showLevel !== false,
24 // 是否显示模块名
25 showModule: options.showModule !== false,
26 // 时间格式
27 timeFormat: options.timeFormat || 'YYYY-MM-DD HH:mm:ss',
28 // 最大日志文件大小 (MB)
29 maxFileSize: options.maxFileSize || 10,
30 // 保留的日志文件数量
31 maxFiles: options.maxFiles || 5
32 }
33
34 // 日志级别映射
35 this.levels = {
36 DEBUG: 0,
37 INFO: 1,
38 WARN: 2,
39 ERROR: 3
40 }
41
42 // Emoji 标签映射
43 this.emojis = {
44 DEBUG: '🔍',
45 INFO: '📝',
46 WARN: '⚠️',
47 ERROR: '❌',
48 SUCCESS: '✅',
49 NETWORK: '🌐',
50 DATABASE: '🗄️',
51 AUTH: '🔐',
52 UPLOAD: '📤',
53 DOWNLOAD: '📥',
54 CACHE: '💾',
55 CONFIG: '⚙️',
56 SERVER: '🚀',
57 CLIENT: '👤',
58 REDIS: '🔴',
59 TOKEN: '🎫',
60 SEARCH: '🔍',
61 CHAT: '💬',
62 MODEL: '🤖',
63 FILE: '📁',
64 TIME: '⏰',
65 MEMORY: '🧠',
66 PROCESS: '⚡'

Callers

nothing calls this directly

Calls 1

initLogDirectoryMethod · 0.95

Tested by

no test coverage detected