MCPcopy Create free account
hub / github.com/Tencent/teamai-cli / writeToFile

Function writeToFile

src/utils/logger.ts:75–89  ·  view source on GitHub ↗

* Append a timestamped line to debug.log. * Synchronous to guarantee delivery in short-lived hook processes. * Silently fails — never throws, never recurses into log.

(level: string, msg: string)

Source from the content-addressed store, hash-verified

73 * Silently fails — never throws, never recurses into log.
74 */
75function writeToFile(level: string, msg: string): void {
76 if (_writing) return; // prevent recursion
77 _writing = true;
78 try {
79 ensureLogDir();
80 maybeRotate();
81 const ts = new Date().toISOString();
82 const line = `${ts} [${level}] ${msg}\n`;
83 fs.appendFileSync(getLogFilePath(), line, 'utf-8');
84 } catch {
85 // silent — file I/O must never disrupt the main flow
86 } finally {
87 _writing = false;
88 }
89}
90
91// ─── Test helpers (not exported in production API) ──────
92

Callers 2

errorFunction · 0.85
debugFunction · 0.85

Calls 3

ensureLogDirFunction · 0.85
maybeRotateFunction · 0.85
getLogFilePathFunction · 0.85

Tested by

no test coverage detected