logging_tools module¶
Logging tools.
- class gemseo.utils.logging_tools.LoggingContext(logger=<RootLogger root (INFO)>, level=30, handler=None, close=True)[source]
Bases:
objectContext manager for selective logging.
Change the level of the logger in a
withblock.Examples
>>> logger = logger.getLogger() >>> logger.setLevel(logging.INFO) >>> logger.info("This should appear.") >>> with LoggingContext(): >>> logger.warning("This should appear.") >>> logger.info("This should not appear.") >>> >>> logger.info("This should appear.")
Source: Logging Cookbook
- Parameters:
logger (logging.Logger) –
The logger.
By default it is set to <RootLogger root (INFO)>.
level (int | None) –
The level of the logger to be used on block entry. If
None, do not change the level of the logger.By default it is set to 30.
handler (logging.StreamHandler | None) – An additional handler to be used on block entry.
close (bool) –
Whether to close the handler on block exit.
By default it is set to True.
- close: bool
Whether to close the handler on block exit.
- handler: logging.StreamHandler
An additional handler to be used on block entry.
- level: int | None
The level of the logger to be used on block entry.
If
None, do not change the level of the logger.
- logger: logging.Logger
The logger.
- class gemseo.utils.logging_tools.MultiLineFileHandler(filename, mode='a', encoding=None, delay=False, errors=None)[source]
Bases:
MultiLineHandlerMixin,FileHandlerFileHandler to split multiline logging messages.
Open the specified file and use it as the stream for logging.
- class gemseo.utils.logging_tools.MultiLineHandlerMixin[source]
Bases:
objectStateless mixin class to override logging handlers behavior.
- emit(record)[source]
Emit one logging message per input record line.
- Return type:
None
- class gemseo.utils.logging_tools.MultiLineStreamHandler(stream=None)[source]
Bases:
MultiLineHandlerMixin,StreamHandlerStreamHandler to split multiline logging messages.
Initialize the handler.
If stream is not specified, sys.stderr is used.