Skip to content

log

Logging of the package, for tracing problems and debugging.

sbmlutils separates output from logging, see sbmlutils.console. What a user asked to see, e.g. the files create_model writes or the report of a validation, is printed on the rich console of the package. The loggers carry what is needed to trace a problem: warnings about content which is lost or a definition which should be fixed, errors of libsbml calls which failed, and debug detail. The package logs nothing at INFO.

sbmlutils follows the convention for libraries: it only gets loggers and logs to them, it does not configure logging. Handlers, levels and formatting are left to the application, which keeps the messages of the package under the control of whoever uses it.

Modules get their logger from the standard library with

import logging

logger = logging.getLogger(__name__)

All loggers are therefore below the sbmlutils logger, so an application configures them in one place:

import logging

logging.getLogger("sbmlutils").setLevel(logging.ERROR)

For scripts and interactive work the warnings and errors can be shown on the rich console of the package, next to its output, which is what the examples do:

from sbmlutils import log

log.enable_rich_logging()

enable_rich_logging

enable_rich_logging(level=INFO, console=None)

Show the warnings and errors of the package on a rich console.

This configures logging and is meant for scripts, examples and interactive work. Applications should configure logging themselves instead of calling this. Calling it repeatedly replaces the handler instead of adding a second one.

Parameters:

Name Type Description Default
level int

level from which messages are logged

INFO
console Console | None

console to log on, the console of the package by default

None

Returns:

Type Description
Logger

The sbmlutils logger.