MCPcopy Create free account
hub / github.com/anomalyco/opencode / formatter

Function formatter

packages/core/src/observability/logging.ts:6–21  ·  view source on GitHub ↗
(id: string = runID)

Source from the content-addressed store, hash-verified

4import { runID } from "./shared"
5
6function formatter(id: string = runID) {
7 return Logger.map(Logger.formatStructured, (output) => {
8 const messages = Array.isArray(output.message) ? output.message : [output.message]
9 return [
10 ["timestamp", output.timestamp],
11 ["level", output.level],
12 ["run", id],
13 ...messages.flatMap((value) => (plain(value) ? flatten(value) : [["message", value] as const])),
14 ...(output.cause === undefined ? [] : [["cause", output.cause] as const]),
15 ...flatten(output.spans),
16 ...flatten(output.annotations),
17 ]
18 .map(([key, value]) => `${key}=${format(value)}`)
19 .join(" ")
20 })
21}
22
23function flatten(
24 input: Record<string, unknown>,

Callers 3

fileLoggerFunction · 0.85
logging.tsFile · 0.85
SessionContextTabFunction · 0.85

Calls 3

plainFunction · 0.85
flattenFunction · 0.70
formatFunction · 0.70

Tested by

no test coverage detected