MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / write

Function write

src/workspaces/logger.ts:35–53  ·  view source on GitHub ↗
(level: Level, msg: string, fields: Record<string, unknown>, toConsole: boolean)

Source from the content-addressed store, hash-verified

33}
34
35function write(level: Level, msg: string, fields: Record<string, unknown>, toConsole: boolean): void {
36 const record: Record<string, unknown> = {
37 ts: new Date().toISOString(),
38 level,
39 msg,
40 ...fields,
41 };
42 const line = JSON.stringify(record, replacer) + '\n';
43 if (toConsole) {
44 if (level === 'error' || level === 'warn') {
45 process.stderr.write(line);
46 } else {
47 process.stdout.write(line);
48 }
49 }
50 if (fileStream) {
51 try { fileStream.write(line); } catch { /* swallow */ }
52 }
53}
54
55function emit(level: Level, msg: string, fields: Record<string, unknown>): void {
56 if (LEVELS[level] < minLevel) return;

Callers 2

emitFunction · 0.85
emitEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected