GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(core): replace legacy logger with Effect logging (#31310) · ainformatico/opencode@c06ad7c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • core
      • src
        • effect
          • logger.ts
          • observability.ts
          • runtime.ts
        • event.ts
        • filesystem
          • ripgrep.ts
          • search.ts
          • watcher.ts
        • models-dev.ts
        • observability.ts
        • observability
          • logging.ts
          • otlp.ts
          • shared.ts
        • project-reference.ts
        • pty.ts
        • session
          • logging.ts
        • skill
          • discovery.ts
        • util
          • log.ts
          • opencode-process.ts
      • test/effect
        • observability.test.ts
    • desktop/src/main
      • env.d.ts
      • sidecar.ts
    • opencode
      • src
        • acp
          • event.ts
          • permission.ts
          • service.ts
          • usage.ts
        • cli
          • cmd
            • acp.ts
            • debug
              • lsp.ts
              • scrap.ts
            • run
              • footer.ts
              • otel.ts
              • runtime.lifecycle.ts
              • runtime.ts
              • scrollback.surface.ts
            • tui.ts
          • heap.ts
          • tui
            • worker.ts
        • config
          • agent.ts
          • command.ts
          • config.ts
          • managed.ts
          • tui-migrate.ts
          • tui.ts
        • control-plane
          • workspace.ts
        • effect
          • app-runtime.ts
          • bootstrap-runtime.ts
          • instance-state.ts
          • run-service.ts
        • format
          • index.ts
        • ide
          • index.ts
        • image
          • image.ts
        • index.ts
        • installation
          • index.ts
        • lsp
          • client.ts
          • lsp.ts
          • server.ts
        • mcp
          • index.ts
          • oauth-callback.ts
          • oauth-provider.ts
        • node.ts
        • patch
          • index.ts
        • permission
          • index.ts
        • plugin
          • digitalocean.ts
          • github-copilot
            • copilot.ts
          • index.ts
          • openai
            • codex.ts
            • ws-pool.ts
          • tui
            • runtime.ts
          • xai.ts
        • project
          • bootstrap.ts
          • instance-store.ts
          • project.ts
          • vcs.ts
        • provider
          • provider.ts
        • question
          • index.ts
        • reference
          • reference.ts
        • server
          • global-lifecycle.ts
          • mdns.ts
          • routes/instance/httpapi
            • handlers
              • control.ts
              • event.ts
              • file.ts
              • global.ts
              • session.ts
              • sync.ts
            • lifecycle.ts
            • middleware
              • error.ts
              • schema-error.ts
            • server.ts
          • server.ts
          • shared
            • fence.ts
        • session
          • compaction.ts
          • llm.ts
          • message-v2.ts
          • processor.ts
          • prompt.ts
          • revert.ts
          • session.ts
          • tools.ts
        • share
          • share-next.ts
        • skill
          • discovery.ts
          • index.ts
        • snapshot
          • index.ts
        • storage
          • storage.ts
        • temporary.ts
        • tool
          • external-directory.ts
          • registry.ts
          • shell.ts
          • truncate.ts
        • worktree
          • index.ts
      • test
        • control-plane
          • workspace.test.ts
        • effect
          • app-runtime-logger.test.ts
        • lsp
          • client.test.ts
        • preload.ts
        • project
          • migrate-global.test.ts
          • project.test.ts
        • server
          • global-session-list.test.ts
          • httpapi-compression.test.ts
          • httpapi-config.test.ts
          • httpapi-cors-vary.test.ts
          • httpapi-event.test.ts
          • httpapi-exercise
            • index.ts
          • httpapi-experimental.test.ts
          • httpapi-file.test.ts
          • httpapi-instance-route-auth.test.ts
          • httpapi-listen.test.ts
          • httpapi-mcp.test.ts
          • httpapi-mdns.test.ts
          • httpapi-provider.test.ts
          • httpapi-pty.test.ts
          • httpapi-reference.test.ts
          • httpapi-session.test.ts
          • httpapi-sync.test.ts
          • httpapi-ui.test.ts
          • httpapi-v2-location.test.ts
          • httpapi-workspace.test.ts
          • project-init-git.test.ts
          • sdk-error-shape.test.ts
          • sdk-v1-smoke.test.ts
          • session-actions.test.ts
          • session-diff-missing-patch.test.ts
          • session-list.test.ts
          • session-messages.test.ts
          • session-select.test.ts
        • session
          • compaction.test.ts
          • messages-pagination.test.ts
          • processor-effect.test.ts
          • prompt.test.ts
          • revert-compact.test.ts
          • session.test.ts
          • snapshot-tool-race.test.ts
          • structured-output-integration.test.ts
        • util
          • log.test.ts
    • server/src/middleware
      • schema-error.ts

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/core/src/effect/logger.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/effect/logger.ts
-73Lines changed: 0 additions & 73 deletions
This file was deleted.
Collapse file

‎packages/core/src/effect/observability.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/effect/observability.ts
-107Lines changed: 0 additions & 107 deletions
This file was deleted.
Collapse file

‎packages/core/src/effect/runtime.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/effect/runtime.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Layer, type Context, ManagedRuntime, type Effect } from "effect"
22
import { memoMap } from "./memo-map"
3-
import { Observability } from "./observability"
3+
import { Observability } from "../observability"
44

55
export function makeRuntime<I, S, E>(service: Context.Service<I, S>, layer: Layer.Layer<I, E>) {
66
let rt: ManagedRuntime.ManagedRuntime<I, E> | undefined
Collapse file

‎packages/core/src/event.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/event.ts
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,7 @@ export const layerWith = (options?: LayerOptions) =>
410410
Effect.catchCauseIf(
411411
(cause) => !Cause.hasInterrupts(cause),
412412
(cause) =>
413-
Effect.logError("Event observer failed").pipe(
414-
Effect.annotateLogs({ eventID: event.id, eventType: event.type, kind, cause }),
415-
),
413+
Effect.logError("Event observer failed", { eventID: event.id, eventType: event.type, kind, cause }),
416414
),
417415
)
418416

Collapse file

‎packages/core/src/filesystem/ripgrep.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/filesystem/ripgrep.ts
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner
1010
import { CrossSpawnSpawner } from "../cross-spawn-spawner"
1111
import { Global } from "../global"
1212
import { NonNegativeInt } from "../schema"
13-
import * as Log from "../util/log"
14-
import { sanitizedProcessEnv } from "../util/opencode-process"
1513
import { which } from "../util/which"
1614

17-
const log = Log.create({ service: "ripgrep" })
1815
const VERSION = "15.1.0"
1916
const PLATFORM = {
2017
"arm64-darwin": { platform: "aarch64-apple-darwin", extension: "tar.gz" },
@@ -146,7 +143,9 @@ export class Service extends Context.Service<Service, Interface>()("@opencode/Ri
146143
export const use = serviceUse(Service)
147144

148145
function env() {
149-
const env = sanitizedProcessEnv()
146+
const env = Object.fromEntries(
147+
Object.entries(process.env).filter((entry): entry is [string, string] => entry[1] !== undefined),
148+
)
150149
delete env.RIPGREP_CONFIG_PATH
151150
return env
152151
}
@@ -307,7 +306,7 @@ export const layer: Layer.Layer<Service, never, FSUtil.Service | ChildProcessSpa
307306
const url = `https://github.com/BurntSushi/ripgrep/releases/download/${VERSION}/${filename}`
308307
const archive = path.join(Global.Path.bin, filename)
309308

310-
log.info("downloading ripgrep", { url })
309+
yield* Effect.logInfo("downloading ripgrep", { url })
311310
yield* fs.ensureDir(Global.Path.bin).pipe(Effect.orDie)
312311

313312
const bytes = yield* HttpClientRequest.get(url).pipe(
@@ -418,7 +417,7 @@ export const layer: Layer.Layer<Service, never, FSUtil.Service | ChildProcessSpa
418417
})
419418

420419
const tree: Interface["tree"] = Effect.fn("Ripgrep.tree")(function* (input: TreeInput) {
421-
log.info("tree", input)
420+
yield* Effect.logInfo("tree", input)
422421
const list = Array.from(yield* files({ cwd: input.cwd, signal: input.signal }).pipe(Stream.runCollect))
423422

424423
interface Node {
Collapse file

‎packages/core/src/filesystem/search.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/filesystem/search.ts
+32-29Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import type { PlatformError } from "effect/PlatformError"
44
import { FSUtil } from "../fs-util"
55
import { Glob } from "../util/glob"
66
import { Global } from "../global"
7-
import * as Log from "../util/log"
87
import { serviceUse } from "../effect/service-use"
98
import { makeRuntime } from "../effect/runtime"
109
import { Fff } from "#fff"
1110
import { Ripgrep } from "./ripgrep"
1211

13-
const log = Log.create({ service: "file.search" })
1412
const root = path.join(Global.Path.cache, "fff")
1513

1614
export type Item = Ripgrep.Item
@@ -220,12 +218,14 @@ export const layer: Layer.Layer<Service, never, FSUtil.Service | Ripgrep.Service
220218
if (!scanned.ok || !scanned.value) {
221219
yield* fffSync("destroy picker", () => pick.destroy()).pipe(Effect.ignore)
222220
state.pick.delete(dir)
223-
log.warn("fff scan not ready", { dir })
221+
yield* Effect.logWarning("fff scan not ready", { dir })
224222
return yield* Effect.fail(new Error(scanned.ok ? "fff scan timed out" : scanned.error))
225223
}
226224

227225
const git = yield* fffSync("refresh git status", () => pick.refreshGitStatus())
228-
if (!git.ok) log.warn("fff git refresh failed", { dir, error: git.error })
226+
if (!git.ok) {
227+
yield* Effect.logWarning("fff git refresh failed", { dir, error: git.error })
228+
}
229229
})
230230

231231
// Create (or return) the picker for a directory. Creation is synchronous
@@ -244,10 +244,7 @@ export const layer: Layer.Layer<Service, never, FSUtil.Service | Ripgrep.Service
244244
if (pending) return yield* Deferred.await(pending)
245245

246246
const available = yield* fffSync("check availability", () => Fff.available()).pipe(
247-
Effect.catch((error) => {
248-
log.warn("fff availability check failed", { error })
249-
return Effect.succeed(false)
250-
}),
247+
Effect.catch((error) => Effect.logWarning("fff availability check failed", { error }).pipe(Effect.as(false))),
251248
)
252249
if (!available) return undefined
253250

@@ -272,7 +269,7 @@ export const layer: Layer.Layer<Service, never, FSUtil.Service | Ripgrep.Service
272269
}),
273270
)
274271
if (!made.ok) {
275-
log.warn("fff init failed", { dir, error: made.error })
272+
yield* Effect.logWarning("fff init failed", { dir, error: made.error })
276273
const err = new Error(made.error)
277274
yield* Deferred.fail(gate, err)
278275
return yield* Effect.fail(err)
@@ -355,14 +352,15 @@ export const layer: Layer.Layer<Service, never, FSUtil.Service | Ripgrep.Service
355352
pageSize: limit,
356353
}),
357354
).pipe(
358-
Effect.catch((error) => {
359-
log.warn(`fff ${kind} search failed`, { dir, query, error })
360-
return Effect.succeed<Fff.Result<string[]> | undefined>(undefined)
361-
}),
355+
Effect.catch((error) =>
356+
Effect.logWarning(`fff ${kind} search failed`, { dir, query, error }).pipe(
357+
Effect.as<Fff.Result<string[]> | undefined>(undefined),
358+
),
359+
),
362360
)
363361
if (!fffResult) return undefined
364362
if (!fffResult.ok) {
365-
log.warn(`fff ${kind} search failed`, { dir, query, error: fffResult.error })
363+
yield* Effect.logWarning(`fff ${kind} search failed`, { dir, query, error: fffResult.error })
366364
return undefined
367365
}
368366

@@ -393,14 +391,15 @@ export const layer: Layer.Layer<Service, never, FSUtil.Service | Ripgrep.Service
393391
timeBudgetMs: 1_500,
394392
}),
395393
).pipe(
396-
Effect.catch((error) => {
397-
log.warn("fff grep failed", { dir, pattern: input.pattern, error })
398-
return Effect.succeed<Fff.Result<Fff.Grep> | undefined>(undefined)
399-
}),
394+
Effect.catch((error) =>
395+
Effect.logWarning("fff grep failed", { dir, pattern: input.pattern, error }).pipe(
396+
Effect.as<Fff.Result<Fff.Grep> | undefined>(undefined),
397+
),
398+
),
400399
)
401400
if (!fffGrep) return yield* rip(input)
402401
if (!fffGrep.ok) {
403-
log.warn("fff grep failed", { dir, pattern: input.pattern, error: fffGrep.error })
402+
yield* Effect.logWarning("fff grep failed", { dir, pattern: input.pattern, error: fffGrep.error })
404403
return yield* rip(input)
405404
}
406405

@@ -432,10 +431,11 @@ export const layer: Layer.Layer<Service, never, FSUtil.Service | Ripgrep.Service
432431
pageSize: limit,
433432
}),
434433
).pipe(
435-
Effect.catch((error) => {
436-
log.warn("fff glob failed", { dir, pattern: input.pattern, error })
437-
return Effect.succeed<Fff.Result<Fff.Search> | undefined>(undefined)
438-
}),
434+
Effect.catch((error) =>
435+
Effect.logWarning("fff glob failed", { dir, pattern: input.pattern, error }).pipe(
436+
Effect.as<Fff.Result<Fff.Search> | undefined>(undefined),
437+
),
438+
),
439439
)
440440

441441
if (fffGlob?.ok) {
@@ -453,7 +453,7 @@ export const layer: Layer.Layer<Service, never, FSUtil.Service | Ripgrep.Service
453453
truncated: fffGlob.value.totalMatched > rows.length,
454454
}
455455
} else if (fffGlob) {
456-
log.warn("fff glob failed", { dir, pattern: input.pattern, error: fffGlob.error })
456+
yield* Effect.logWarning("fff glob failed", { dir, pattern: input.pattern, error: fffGlob.error })
457457
// fall through to the fallback
458458
}
459459
}
@@ -500,13 +500,16 @@ export const layer: Layer.Layer<Service, never, FSUtil.Service | Ripgrep.Service
500500
if (!entry) return
501501

502502
const out = yield* fffSync("track query", () => entry.pick.trackQuery(row.text, file)).pipe(
503-
Effect.catch((error) => {
504-
log.warn("fff track query failed", { dir: row.dir, query: row.text, file, error })
505-
return Effect.succeed<Fff.Result<boolean> | undefined>(undefined)
506-
}),
503+
Effect.catch((error) =>
504+
Effect.logWarning("fff track query failed", { dir: row.dir, query: row.text, file, error }).pipe(
505+
Effect.as<Fff.Result<boolean> | undefined>(undefined),
506+
),
507+
),
507508
)
508509
if (!out) return
509-
if (!out.ok) log.warn("fff track query failed", { dir: row.dir, query: row.text, file, error: out.error })
510+
if (!out.ok) {
511+
yield* Effect.logWarning("fff track query failed", { dir: row.dir, query: row.text, file, error: out.error })
512+
}
510513
})
511514

512515
return Service.of({ files, tree, search, file, glob, open, warm, release })

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.