diff options
| author | Dax Raad <[email protected]> | 2025-06-09 15:00:48 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-06-09 15:00:48 -0400 |
| commit | 60faa26a153ab4e468f5a30f9be41146209c4865 (patch) | |
| tree | 8c691fafc1d0ac40a98ba9feb0ad9aba187d9092 | |
| parent | d8510ab452c72e5c43c8608c212f9a2e4053c23f (diff) | |
| download | opencode-60faa26a153ab4e468f5a30f9be41146209c4865.tar.gz opencode-60faa26a153ab4e468f5a30f9be41146209c4865.zip | |
sync
| -rw-r--r-- | packages/opencode/src/app/app.ts | 5 | ||||
| -rw-r--r-- | packages/opencode/src/index.ts | 2 | ||||
| -rw-r--r-- | packages/opencode/src/util/log.ts | 11 |
3 files changed, 16 insertions, 2 deletions
diff --git a/packages/opencode/src/app/app.ts b/packages/opencode/src/app/app.ts index c6c34cf2c..2d0bcb414 100644 --- a/packages/opencode/src/app/app.ts +++ b/packages/opencode/src/app/app.ts @@ -33,9 +33,14 @@ export namespace App { const APP_JSON = "app.json" async function create(input: { cwd: string; version: string }) { + log.info("creating", { + cwd: input.cwd, + version: input.version, + }) const git = await Filesystem.findUp(".git", input.cwd).then((x) => x ? path.dirname(x) : undefined, ) + log.info("git", { git }) const data = path.join( Global.Path.data, diff --git a/packages/opencode/src/index.ts b/packages/opencode/src/index.ts index 65c064e5b..34ff0b684 100644 --- a/packages/opencode/src/index.ts +++ b/packages/opencode/src/index.ts @@ -17,7 +17,7 @@ import { VERSION } from "./cli/version" import { ScrapCommand } from "./cli/cmd/scrap" import { Log } from "./util/log" -await Log.init({ print: false }) +await Log.init({ print: process.argv.includes("--print-logs") }) yargs(hideBin(process.argv)) .scriptName("opencode") diff --git a/packages/opencode/src/util/log.ts b/packages/opencode/src/util/log.ts index 74b901053..04323240c 100644 --- a/packages/opencode/src/util/log.ts +++ b/packages/opencode/src/util/log.ts @@ -2,16 +2,24 @@ import path from "path" import fs from "fs/promises" import { Global } from "../global" export namespace Log { + const Default = create() + export interface Options { print: boolean } + let logpath = "" + + export function file() { + return logpath + } + export async function init(options: Options) { const dir = path.join(Global.Path.data, "log") await fs.mkdir(dir, { recursive: true }) cleanup(dir) if (options.print) return - const logpath = path.join(dir, new Date().toISOString() + ".log") + logpath = path.join(dir, new Date().toISOString().split(".")[0] + ".log") const logfile = Bun.file(logpath) await fs.truncate(logpath).catch(() => {}) const writer = logfile.writer() @@ -20,6 +28,7 @@ export namespace Log { writer.flush() return true } + Default.info("initialized", { file: logpath }) } async function cleanup(dir: string) { |
