0
0
Drone Programmingprogramming~30 mins

Logging and log analysis in Drone Programming - Mini Project: Build & Apply

Choose your learning style9 modes available
Logging and Log Analysis with Drone Programming
📖 Scenario: You are working on a drone control system. To keep track of the drone's activities and detect problems, you need to create logs that record important events and then analyze these logs to find any errors.
🎯 Goal: Build a simple logging system that records drone events with their severity levels, then filter and display only the error logs for quick analysis.
📋 What You'll Learn
Create a list of log entries with exact event messages and severity levels
Add a variable to specify the severity level to filter logs
Use a loop or comprehension to select logs matching the filter severity
Print the filtered error logs exactly as specified
💡 Why This Matters
🌍 Real World
Logging is essential in drone systems to monitor flight status and detect issues early. Filtering logs helps engineers focus on critical problems quickly.
💼 Career
DevOps and site reliability engineers use logging and log analysis daily to maintain system health and troubleshoot errors efficiently.
Progress0 / 4 steps
1
Create the initial log entries list
Create a list called logs with these exact entries as dictionaries: {'event': 'Takeoff initiated', 'level': 'INFO'}, {'event': 'Altitude reached 100m', 'level': 'INFO'}, {'event': 'Battery low', 'level': 'WARNING'}, {'event': 'Motor failure detected', 'level': 'ERROR'}, {'event': 'Landing completed', 'level': 'INFO'}
Drone Programming
Need a hint?

Use a list of dictionaries. Each dictionary must have keys 'event' and 'level' with exact string values.

2
Add a filter level variable
Create a variable called filter_level and set it to the string 'ERROR' to specify which log level to filter.
Drone Programming
Need a hint?

Just assign the string 'ERROR' to the variable filter_level.

3
Filter logs by severity level
Create a list called error_logs that contains only the entries from logs where the 'level' matches the filter_level. Use a list comprehension.
Drone Programming
Need a hint?

Use a list comprehension to select logs where log['level'] == filter_level.

4
Print the filtered error logs
Use a for loop to print each dictionary in error_logs exactly as it appears.
Drone Programming
Need a hint?

Use a for loop to print each dictionary in error_logs.