A new joiner asks why your team's scripts all use `logging.getLogger(__name__)` instead of the root logger. How do you explain it?
BeginnerScenarioAutomation scripting & CLI design
Answer
Situation read → Teaching moment about logger hierarchy.
What I'd do →
- Explain that named loggers show which module emitted a line (
cloudaudit.checks). - Levels can be tuned per module:
logging.getLogger("cloudaudit.checks").setLevel("DEBUG")without drowning in botocore debug logs. - Libraries should never configure the root logger; the application does it once in
main().
Why → Named loggers give control and context for free.
Interview tip → Mention silencing botocore and urllib3 to WARNING as a practical example.
More on Automation scripting & CLI design
Your team has a 300-line Bash script that parses JSON with `jq`, loops over AWS accounts and retries with `sleep`. It breaks every month. Do you rewrite it in Python?BeginnerA colleague's script deletes files older than 30 days from `/var/log/app`. You are asked to review it before it goes into cron. What do you look for?IntermediateYou need a script that ops engineers run from laptops and that CI runs nightly. How do you design its interface?IntermediateA script reads a 15 GB access log to count 5xx errors per endpoint, and the box runs out of memory. How do you fix it?BeginnerYou must run the same Python automation on 40 servers that have Python 3.6, 3.9 and 3.12. What do you do?IntermediateA cron job that runs a Python script fails silently. Nobody noticed for two weeks. How do you make sure that never happens again?Intermediate