C/C++ Arena

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

Example: log_line(Level::Warn, 65250ms, "disk 91%") is [00:01:05.250] WARN disk 91%.

Previous: Strict number parsing with from_chars