Lab 1 of 5
Β·
Guided
Add Logging to a Device Script
Objective: Configure the logging module and write log messages at the correct severity levels.
Instructions
Create a file called lab1.py. Configure the logging module and write four log messages.
Requirements:
- Format: %(levelname)s %(message)s β no timestamp
- Level: INFO (DEBUG messages must not appear)
Write these four log events in order:
- INFO β
Starting device inventory check - INFO β
Processing sw-core-01 - WARNING β
sw-access-02 did not respond - ERROR β
Failed to process rtr-edge-01
Your output must match exactly:
INFO Starting device inventory check
INFO Processing sw-core-01
WARNING sw-access-02 did not respond
ERROR Failed to process rtr-edge-01
Run it with python3 lab1.py. Paste your output below and submit.
π‘ Show Hint
import logging. logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s"). Then logging.info(), logging.warning(), and logging.error() for the four messages. No timestamp needed β leave datefmt out of basicConfig.
Paste Your Output