Step 6 of 6
Challenge: a log formatter
Every service writes logs, and consistent, sortable, greppable log lines matter when you're debugging production at 3 a.m.
Your turn: write std::string log_line(Level level, std::chrono::milliseconds uptime, std::string_view msg) producing:
[HH:MM:SS.mmm] LEVEL message
- the uptime as zero-padded hours, minutes, seconds and milliseconds (hours can exceed 24)
- the level name (
DEBUG,INFO,WARN,ERROR) left-aligned in 5 characters - one space, then the message
Example: log_line(Level::Warn, 65250ms, "disk 91%") is [00:01:05.250] WARN disk 91%.