Logging and debugging#
The new inversion framework uses the logging module to print messages while inversions are run.
Some classes and functions of the new framework will log events like starting a new iteration, caching a result, updating some parameter, etc.
These events are logged through a global logging.Logger that we can access through the inversion_ideas.utils.get_logger() function.
import inversion_ideas as ii
logger = ii.utils.get_logger()
Logging messages#
Users can use this logger to log messages in their own codes.
For example, we can log an logging.INFO message through the logging.Logger.info() method:
import inversion_ideas as ii
logger = ii.utils.get_logger()
logger.info("This is a custom message")
[INFO] This is a custom message
Or a logging.DEBUG message through the logging.Logger.debug() method:
logger.debug("This is a custom debug message")
Note
Debug messages are not shown by default. Learn how to adjust the logging level so they can be shown.
Adjusting the logging level#
By default this logger will only print out messages of the logging.INFO level or above.
Many of the messages logged by the framework’s functions and classes are under the logging.DEBUG category.
If we want to receive those messages we need to adjust the logging level of the logger, for example:
import inversion_ideas as ii
logger = ii.utils.get_logger()
logger.setLevel("DEBUG")
logger.debug("This is a custom debug message")
[DEBUG] This is a custom debug message