-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaudit.js
More file actions
22 lines (20 loc) · 670 Bytes
/
Copy pathaudit.js
File metadata and controls
22 lines (20 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Phase 1: stdout-only audit shim. Every command that crosses the relay is
// logged here for protocol debugging. Phase 3 will add a journal-page sink for
// the AAGM channel - at that point this becomes a wrapper around both.
export class Audit {
constructor({ stdout = true } = {}) {
this.toStdout = stdout;
}
log(event, data = {}) {
if (!this.toStdout) return;
const ts = new Date().toISOString();
let payload;
try {
payload = JSON.stringify(data);
} catch (err) {
payload = `<unserializable: ${err.message}>`;
}
// One line per event so it stays grep-friendly.
console.log(`${ts} ${event} ${payload}`);
}
}