Using log messages
Writing messages to the log file is useful for monitoring and auditing running systems. It can also help with code maintenance, making it easier to get debug information from running processes, without the need to change code.
To use logging in Odoo code, first, a logger object must be prepared. For this, add the following code lines at the top of the library_checkout/wizard/checkout_mass_message.py
file:
import logging _logger = logging.getLogger(__name__)
The logging
Python standard library module is being used here. The _logger
object is initialized using the name of the current code file, __name__
. With this, the log messages will include information about the file that generated them.
There are several levels available for log messages. These are as follows:
_logger.debug('A DEBUG message') _logger.info('An INFO message') _logger.warning('A WARNING message') _logger.error('An ERROR message')
We can...