In any modern programming language, the logging facilities are provided with common features. Similarly, Python's logging module is very rich in features and flexibilities. We can use the different types of log handlers with the logging module, such as the console or the file logging handler. One way in which you can maximize your logging benefits is by e-mailing the log messages to the user just as the log is being produced. Python's logging module provides a type of handler called BufferingHandler,
which is capable of buffering the log data.
An example of extending BufferingHandler
has been displayed later. A child class called BufferingSMTPHandler
is defined by BufferingHandler
. In this example, an instance of the logger object is created by using the logging module. Then, an instance of BufferingSMTPHandler
is tied to this logger object. The logging level is set to DEBUG so that it can log any message. A sample list of four words has been used for...