Logging

These mass updates could be misused, so it may be a good idea to log some information when the updates happen. The preceding code initializes the _logger in the two lines before the TodoWizard class, using the Python logging standard library. The Python __name__ internal variable is to identify the messages as coming from this module.

To write log messages in method code, we can use:

_logger.debug('A DEBUG message') 
_logger.info('An INFO message') 
_logger.warning('A WARNING message') 
_logger.error('An ERROR message') 

When passing values to use in the log message, instead of using string interpolation, we should provide them as additional parameters. For example, instead of _logger.info('Hello %s' % 'World') we should use _logger.info('Hello ...

Get Odoo 11 Development Essentials - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.