diff --git a/src/shared/index.ts b/src/shared/index.ts index c6f7ca8..9ce0414 100644 --- a/src/shared/index.ts +++ b/src/shared/index.ts @@ -2,3 +2,4 @@ export * from "./frontmatter" export * from "./command-executor" export * from "./file-reference-resolver" export * from "./model-sanitizer" +export * from "./logger" diff --git a/src/shared/logger.ts b/src/shared/logger.ts new file mode 100644 index 0000000..23f48be --- /dev/null +++ b/src/shared/logger.ts @@ -0,0 +1,20 @@ +// Shared logging utility for the plugin + +import * as fs from "fs" +import * as os from "os" +import * as path from "path" + +const logFile = path.join(os.tmpdir(), "oh-my-opencode.log") + +export function log(message: string, data?: unknown): void { + try { + const timestamp = new Date().toISOString() + const logEntry = `[${timestamp}] ${message} ${data ? JSON.stringify(data) : ""}\n` + fs.appendFileSync(logFile, logEntry) + } catch { + } +} + +export function getLogFilePath(): string { + return logFile +}