-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathlog.js
More file actions
16 lines (14 loc) · 602 Bytes
/
Copy pathlog.js
File metadata and controls
16 lines (14 loc) · 602 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// agent-orders — structured, single-line JSON logging. Keypairs/secrets never
// reach here; callers pass only ids, mints, amounts, and reasons.
function emit(level, msg, meta) {
const rec = { t: new Date().toISOString(), level, msg, ...(meta || {}) };
const line = JSON.stringify(rec);
if (level === 'error' || level === 'warn') console.error(line);
else console.log(line);
}
export const log = {
info: (msg, meta) => emit('info', msg, meta),
warn: (msg, meta) => emit('warn', msg, meta),
error: (msg, meta) => emit('error', msg, meta),
trade: (msg, meta) => emit('trade', msg, meta),
};