MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / write

Method write

lib/logger.ts:70–89  ·  view source on GitHub ↗
(level: string, component: string, message: string, data?: any)

Source from the content-addressed store, hash-verified

68 }
69
70 private async write(level: string, component: string, message: string, data?: any) {
71 if (!this.enabled) return
72
73 try {
74 await this.ensureLogDir()
75
76 const timestamp = new Date().toISOString()
77 const dataStr = this.formatData(data)
78
79 const logLine = `${timestamp} ${level.padEnd(5)} ${component}: ${message}${dataStr ? " | " + dataStr : ""}\n`
80
81 const dailyLogDir = join(this.logDir, "daily")
82 if (!existsSync(dailyLogDir)) {
83 await mkdir(dailyLogDir, { recursive: true })
84 }
85
86 const logFile = join(dailyLogDir, `${new Date().toISOString().split("T")[0]}.log`)
87 await writeFile(logFile, logLine, { flag: "a" })
88 } catch (error) {}
89 }
90
91 info(message: string, data?: any) {
92 const component = this.getCallerFile(2)

Callers 4

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

Calls 2

ensureLogDirMethod · 0.95
formatDataMethod · 0.95

Tested by

no test coverage detected