Logging events and conditions
A well-behaved application can produce a variety of processing summaries. For command-line applications, the summary might be a simple "everything went okay" message. For GUI applications, this summary is inverted—silence means things are working well, and a dialog box with an error message indicates things didn't work properly.
In some command-line processing contexts, the summary might include some additional details on the number of objects that were processed. In financial applications, some counts and the total values of various objects must balance properly to show that all objects that were received as input became proper outputs.
When we need additional details, beyond a simple "works or breaks" summary, we can leverage the print()
function. The output can be redirected to the sys.stderr
file to produce a handy log. While this is effective in small programs, it has a number of desirable features offered by the logging
module...