O'Reilly logo

Modern Python Cookbook by Steven F. Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required