How to do it...

  1. We'll start by implementing basic logging features into the existing functions. This means that we'll need the logging module:
        import logging

The rest of the application will use a number of other packages:

        import argparse 
        import sys 
        from pathlib import Path 
        from collections import Counter 
        import yaml 
  1. We'll create two logger objects as module globals. The creating functions can go anywhere in the script that creates global variables. One location is to put these early, after the import statements. Another common choice is near the end, but outside any __name__ == "__main__" script processing. These variables must always be created, even if the module is imported as a library.


Loggers have hierarchical names. We'll ...

Get Modern Python Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.