teacher
Sign in

Logging Framework

Design a small logging library with levels, a chain of handlers, pluggable appenders and formatters, and a singleton logger.

45 min4 interactive

Requirements

QuestionDecision
What are the levels?DEBUG, INFO, WARN, ERROR, in increasing severity
Can one message go to several places?Yes. Console for warnings, a file for everything, an alert channel for errors
Can each place format differently?Yes. A plain line on the console, a detailed line in the file
Can the level change while running?Yes. A global threshold drops anything below it
Thread safety?Many threads log at once. Lines must not interleave
One logger or many?One shared logger here. Named loggers are an extension

Out of scope: real timestamps and files, rotation, configuration files, structured (JSON) logs.

1 of 9