Logging in Python
When you write scripts that are run from the command line, the messages usually appear in the same terminal where they are running. We can improve this aspect by introducing some type of message recording mechanism, either in a file or in a database.
Python provides the Logging module (https://docs.python.org/3/library/logging.html) as a part of the standard library. Logging in Python is built around a hierarchical structure of logger instances. Among the main use cases of this module, we can highlight the following:
- Debugging: Where source code is examined when searching for bugs and errors.
- IT Forensic Analysis: In order to identify the cause of security incidents, such as hacker attacks, we may have a log file available.
- IT Audit: A log audit can help determine whether user actions are occurring as expected and whether the security and integrity of the data are guaranteed.
After introducing the logging module, we will continue to study...