MCPcopy Create free account
hub / github.com/cortexkit/magic-context / log

Function log

packages/plugin/src/shared/logger.ts:56–75  ·  view source on GitHub ↗
(message: string, data?: unknown)

Source from the content-addressed store, hash-verified

54}
55
56export function log(message: string, data?: unknown): void {
57 if (isTestEnv) return;
58 try {
59 const timestamp = new Date().toISOString();
60 const serialized =
61 data === undefined
62 ? ""
63 : data instanceof Error
64 ? ` ${data.message}${data.stack ? `\n${data.stack}` : ""}`
65 : ` ${JSON.stringify(data)}`;
66 buffer.push(`[${timestamp}] ${message}${serialized}\n`);
67 if (buffer.length >= BUFFER_SIZE_LIMIT) {
68 flush();
69 } else {
70 scheduleFlush();
71 }
72 } catch {
73 // Intentional: logging must never throw
74 }
75}
76
77export function sessionLog(sessionId: string, message: string, data?: unknown): void {
78 log(`[magic-context][${sessionId}] ${message}`, data);

Callers 15

serverFunction · 0.90
openTimerDatabaseOrNullFunction · 0.90
startDreamScheduleTimerFunction · 0.90
runTickFunction · 0.90
sweepProjectFunction · 0.90
sweepGitCommitsFunction · 0.90
logConfigFailureOnceFunction · 0.90
buildSidebarSnapshotFunction · 0.90
buildStatusDetailFunction · 0.90

Calls 2

scheduleFlushFunction · 0.85
flushFunction · 0.70

Tested by

no test coverage detected