INNER CODE UNIT · JavaScript
log
karanb192/claude-code-hooks · plugins/bounty-board/bounty-board.js:107
function log(data) {
try {
if (!fs.existsSync(LOG_DIR)) fs.mkdirSync(LOG_DIR, { recursive: true });
const file = path.join(LOG_DIR, `${new Date().toISOString().slice(0, 10)}.jsonl`);
fs.appendFileSync(file, JSON.stringify({ ts: new Date().toISOString(), hook: 'bounty-board', ...data }) + '\n');
} catch {}
}
// ── Pure helpers ──────────────────────────────────────────────────────────────
/** Stable id for a bounty so the same line survives across sessions. */
function bountyId(relPath, ruleId, text) {
return crypto
.createHash('sha1')
.update(`${relPath}\u0000${ruleId}\u0000${text.trim()}`)
.digest('hex')
.slice(0, 12);
}