Skip to content

log

Logging of the package.

sbmlsim 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 sbmlsim logger, so an application configures them in one place:

import logging

logging.getLogger("sbmlsim").setLevel(logging.WARNING)

For scripts and interactive work the rich formatting of the package can be enabled explicitly, which is what the examples do:

from sbmlsim import log

log.enable_rich_logging()

enable_rich_logging

enable_rich_logging(level=INFO, console=None)

Log the messages 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 sbmlsim logger.

some_ids

some_ids(ids, n=5)

Get the first ids of a list and how many there are, for a message.

The ids a message lists can be the elements of a network, which are hundreds or thousands.

Parameters:

Name Type Description Default
ids Sequence[str]

the ids.

required
n int

how many of them are listed.

5

Returns:

Type Description
str

The ids as a list, followed by the count when there are more than n.