MCPcopy Create free account
hub / github.com/cloudflare/computer / formatLogEntry

Function formatLogEntry

packages/computerd/src/cli/logger.ts:25–37  ·  view source on GitHub ↗
(level: LogLevel, args: unknown[])

Source from the content-addressed store, hash-verified

23}
24
25export function formatLogEntry(level: LogLevel, args: unknown[]): string {
26 const timestamp = new Date().toISOString();
27 const body = args
28 .map((arg) => {
29 if (arg instanceof Error) {
30 return arg.stack ?? `${arg.name}: ${arg.message}`;
31 }
32 if (typeof arg === "string") return arg;
33 return inspect(arg, { depth: 4, breakLength: 120 });
34 })
35 .join(" ");
36 return `${timestamp} [${level}] ${body}`;
37}
38
39// Open the log file in append mode. The fd survives across writes so
40// we don't pay an open/close per line. Throws if the path's directory

Callers 2

writeFunction · 0.85
logger.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected