Chapter 10. Adding Permanency to Python Tools

Python has enormous capabilities, and we have only scratched the surface of the tools and techniques available for us as assessors. We are going to cover a few of the more advanced features of the Python language that can be helpful to us. Specifically, we are going to highlight how we can build logging into our scripts and then develop multithreaded and multiprocessing tools. Adding in these more advanced capabilities means that the tools you develop will be more resilient to the test of time and stand apart from other solutions.

Understanding logging within Python

As you write your own modules, such as the one highlighted in Chapter 9, Automating Reports and Tasks with Python, you would want to be able to track errors, warnings, and debug messages easily. The logger library allows you to track events and output them to Standard Error (STDERR), files, and Standard Output (STDOUT). The benefit to using logger is that the format can be easily defined and sent to the relevant output using specific message types. The messages are similar to syslog messages, and they mimic the same logging levels.

Note

More details about the logger library can be found at https://docs.python.org/2/library/logging.html.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset