(hookName, overrideCfg)
| 43 | const noop = () => {}; |
| 44 | |
| 45 | export function createLogger(hookName, overrideCfg) { |
| 46 | const c = overrideCfg || cfg(); |
| 47 | if (!c.debug) return { log: noop, logError: noop }; |
| 48 | |
| 49 | const logPath = c.debugLogPath; |
| 50 | ensureDir(logPath); |
| 51 | |
| 52 | function log(stage, data) { |
| 53 | writeLine(logPath, { ts: localISO(), hook: hookName, stage, data }); |
| 54 | } |
| 55 | |
| 56 | function logError(stage, err) { |
| 57 | const error = err instanceof Error |
| 58 | ? { message: err.message, stack: err.stack } |
| 59 | : String(err); |
| 60 | writeLine(logPath, { ts: localISO(), hook: hookName, stage, error }); |
| 61 | } |
| 62 | |
| 63 | return { log, logError }; |
| 64 | } |
no test coverage detected