All files / apps / api/src / lib log.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8          55x    
type Level = 'info' | 'warn' | 'error'
 
// One JSON line per event, so Workers Logs can filter on a field (design G5).
// Log ids and codes only: never a token, an MFA code or message text (design 6.2 V14, V16).
export function log(level: Level, fields: Record<string, unknown>): void {
  console[level](JSON.stringify({ level, ...fields }))
}