matrix-plugin/logger.ts

20 lines
503 B
TypeScript

import fs from "fs"
import os from "os"
import path from "path"
const LOG_DIR = path.join(os.homedir(), ".opencode-matrix-plugin")
const LOG_FILE = path.join(LOG_DIR, "plugin.log")
export function setLogDir(dir: string): void {
// no-op: LOG_FILE is already set to the correct location
}
export function log(message: string): void {
try {
fs.mkdirSync(LOG_DIR, { recursive: true })
fs.appendFileSync(LOG_FILE, `[${new Date().toISOString()}] ${message}\n`)
} catch {
// silent
}
}