Skip to main content

Practice ยท 1 of 2

Structured logging, executed

1. static String format(java.util.Map<String, String> fields) โ€” return a deterministic line: keys SORTED alphabetically, each as key=value, joined by a single space. Empty map โ†’ empty string. 2. static java.util.Map<String, String> parse(String line) โ€” the inverse: split on single spaces, split each token on the FIRST '=', build the map. 3. static List<String> levelOf(List<String> lines) โ€” extract the value of "level" from each line via parse(). 4. static List<String> actionFor(String level) โ€” the level contract as data: "ERROR"โ†’["page"], "WARN"โ†’["watch"], "INFO"โ†’["ignore"], unknownโ†’["investigate"].

Difficulty: advanced

Back to lesson: Practice: Observability drills