This iteration fixes one issue of our script by recording execution "metadata." Really, we're using a log to create a chain of custody for the script. Our chain of custody will inform a third party what our script did at various points in time and any errors encountered. Did we mention the traditional purpose of logging is for debugging? Nevertheless, our forensically commandeered log will be suitable in either scenario. This will serve as a brief tutorial on the basics of the
logging
module by using it in a real example. For more examples and references, please refer to the documentation at http://docs.python.org/2/library/logging.html.
We have added two modules to our imports: os
and logging
. If a desired log directory is supplied by the user, we will use the os
module to append that directory and update the path of our log. In order to write a log, we will use the logging
module. Both of these modules are part of the standard library...