Replace bare print() calls with Python's stdlib logging module to emit structured, level-based output, then use sys.exit() with meaningful non-zero codes so CI/CD pipelines can detect failures automatically.
Create a directory for this lesson, copy `deploy_check.py` from Lesson 103, and confirm the virtual environment is active. Lesson 104 evolves the script by replacing print() with logging and adding explicit sys.exit() calls.
mkdir -p ~/devops-python/lesson-104cd ~/devops-python/lesson-104cp ~/devops-python/lesson-103/deploy_check.py .source ~/devops-python/lesson-101/devops-env/bin/activatecat deploy_check.pyYou are starting from the Lesson 103 version of deploy_check.py, which uses argparse for argument parsing.
By the end of this lesson the script will use the logging module for all diagnostic output and exit with a non-zero code when it encounters an application-level error.
The logging module is part of the Python standard library ā no pip install required.
Your terminal prompt shows (devops-env). cat deploy_check.py shows the Lesson 103 script: shebang, argparse setup with environment, --format, and --verbose arguments, and print() calls for output.