Results for “logs”

Showing 1–10 of 13

  1. Challenge

    Log line format

    …mission log, one line per event. Engineers search those logs, tools filter them by level, and alarms go off when an ERROR line appears. That only works if every line has exactly the same shape…

    Write the code Easy 2 stages f-strings print logs formatting
  2. Challenge

    Log analyser

    Turn the launch-day mission log into answers: parse each line into a dict, count the entries per level and per hour, find the first ERROR, then rank the subsystems by how many warnings they raised.

    Write the code Hard 3 stages project logs parsing Counter
  3. Challenge

    Log to a file

    Write the day's mission log entries to mission.log with with open(), one per line, read the file back and print it, then add an append_entry() function that adds lines at the end without wiping what…

    Write the code Easy 2 stages files open with write
  4. Challenge

    Extra log fields

    Extend format_log() from "Log formatter function" with **fields, so any extra keyword arguments are added to the line as key=value pairs, then pass whole dicts of fields into it with ** at the call.

    Write the code Medium 2 stages functions **kwargs keyword arguments dictionaries
  5. Challenge

    Log formatter function

    Move the mission log's f-string into format_log(t, level, msg), a function that returns the line instead of printing it, then fix the alignment of every log line with one change inside the function.

    Fix the code Easy 2 stages functions def return refactoring
  6. Challenge

    Entries per level

    Count the mission log's entries per level, INFO, WARN and ERROR, in a dict of counters, then count any level at all with get() when DEBUG lines turn up, and print the levels in alphabetical order.

    Write the code Easy 2 stages dictionaries counting get sorted
  7. Challenge

    Filter the log

    Go through the mission log and build a new list holding only the WARN and ERROR entries with append(), then let a minimum level decide what counts, the way logging tools filter by severity.

    Write the code Medium 2 stages for loop lists append filtering
  8. Challenge

    First error

    Scan the mission log for the first ERROR entry, print its line number with enumerate() and stop there with break, then report how many lines were checked, or that there were no errors at all.

    Write the code Easy 2 stages for loop break enumerate flags
  9. Challenge

    Count warnings

    Count the entries and the WARN lines in a multi-line mission log with count(), fix the count when a message mentions WARN itself, then summarise the log by level.

    Write the code Medium 3 stages strings count multi-line strings logs
  10. Challenge

    Redact the access code

    Replace all but the last four characters of an access code with * using len(), slicing and string repetition, then find a code inside a log line and mask it there before the line is saved.

    Write the code Medium 2 stages strings slicing len replace