gemseo / utils

Show inherited members

logging_tools module

Logging tools.

class gemseo.utils.logging_tools.LoggingContext(logger=<RootLogger root (INFO)>, level=30, handler=None, close=True)[source]

Bases: object

Context manager for selective logging.

Change the level of the logger in a with block.


>>> logger = logger.getLogger()
>>> logger.setLevel(logging.INFO)
>>>"This should appear.")
>>> with LoggingContext():
>>>    logger.warning("This should appear.")
>>>"This should not appear.")
>>>"This should appear.")

Source: Logging Cookbook

  • logger (logging.Logger) –

    The logger.

    By default it is set to <RootLogger root (INFO)>.

  • level (int) –

    The level of the logger to be used on block entry.

    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.

class gemseo.utils.logging_tools.MultiLineFileHandler(filename, mode='a', encoding=None, delay=False, errors=None)[source]

Bases: MultiLineHandlerMixin, FileHandler

FileHandler 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: object

Stateless mixin class to override logging handlers behavior.


Emit one logging message per input record line.

Return type:


class gemseo.utils.logging_tools.MultiLineStreamHandler(stream=None)[source]

Bases: MultiLineHandlerMixin, StreamHandler

StreamHandler to split multiline logging messages.

Initialize the handler.

If stream is not specified, sys.stderr is used.