22 lines
592 B
TypeScript
22 lines
592 B
TypeScript
import fs from "fs"
|
|
import path from "path"
|
|
|
|
const LOG_DIR = "/tmp/opencode-matrix-plugin"
|
|
const LOG_FILE = path.join(LOG_DIR, "plugin.log")
|
|
|
|
export function log(message: string): void {
|
|
try {
|
|
const timestamp = new Date().toISOString()
|
|
const line = `[${timestamp}] ${message}\n`
|
|
fs.mkdirSync(LOG_DIR, { recursive: true })
|
|
fs.appendFileSync(LOG_FILE, line)
|
|
} catch (e) {
|
|
try {
|
|
const timestamp = new Date().toISOString()
|
|
fs.appendFileSync("/tmp/opencode-matrix-fallback.log", `[${timestamp}] ${message}\n`)
|
|
} catch {
|
|
// silent fallback
|
|
}
|
|
}
|
|
}
|