Book Image

Python Essentials

By : Steven F. Lott
Book Image

Python Essentials

By: Steven F. Lott

Overview of this book

Table of Contents (22 chapters)
Python Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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.

The first step in using the...