refactor(core): replace legacy logger with Effect logging (#31310)

This commit is contained in:
Dax 2026-06-08 15:41:56 -04:00 committed by GitHub
commit c06ad7c881
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
152 changed files with 697 additions and 2242 deletions

View file

@ -1,9 +1,7 @@
import * as Log from "@opencode-ai/core/util/log"
import { Effect } from "effect"
import { HttpApiMiddleware } from "effect/unstable/httpapi"
import { InvalidRequestError } from "../errors"
const log = Log.create({ service: "server" })
const REASON_LIMIT = 1024
function truncateReason(reason: string) {
@ -18,6 +16,8 @@ export class SchemaErrorMiddleware extends HttpApiMiddleware.Service<SchemaError
export const schemaErrorLayer = HttpApiMiddleware.layerSchemaErrorTransform(SchemaErrorMiddleware, (error) => {
const reason = truncateReason(error.cause.message)
log.warn("schema rejection", { kind: error.kind, reason })
return Effect.fail(new InvalidRequestError({ message: reason, kind: error.kind }))
return Effect.logWarning("schema rejection").pipe(
Effect.annotateLogs({ kind: error.kind, reason }),
Effect.andThen(Effect.fail(new InvalidRequestError({ message: reason, kind: error.kind }))),
)
})