Skip to main content

Practice ยท 1 of 2

Logs a machine can query, a lawyer can read

Implement StructuredLogger(correlation_id): - log(level, event, **fields) appends a JSON line (sorted keys) containing level, event, correlation_id, and the fields - any field named in SENSITIVE = {'password', 'token', 'secret', 'card_number'} is emitted as '[REDACTED]' โ€” redaction happens at emit time - convenience methods info(event, **fields) and error(event, **fields) map to levels 'INFO' and 'ERROR' - expose the lines as a lines list The redaction test is the point: a login event carrying a password must never emit the password.

Difficulty: advanced

Back to lesson: Practice: Observability Drills