mylogging.config_module module

Module with functions for ‘config’ subpackage.

class mylogging.config_module.Config[source]

Bases: object

Usually used created instace from this module called config as usually no need of another instances… All variables has own docstrings.

property around: typing_extensions.Literal[True, False, auto]

separate logs with ===== and line breaks for better visibility.

False: keep message short

“auto”: False if output == “file/path”, True if output == “console”

Defaults to: “auto”

Type

True

property blacklist: list[str]

Log messages can be filtered out. Only part of message can be used. Numeric letters are removed in message comparison, to be able to filter out same errors from different places. Only last 100 messages is kept in memory…

Example: [“Matrix inversion failed”]

Defaults to: None

property colorize: typing_extensions.Literal[True, False, auto]

Whether colorize results.

Options: [True, False, ‘auto’]

Defaults to: ‘auto’

‘auto’ means color if to console, not color if to file.

property console_log_or_warn: typing_extensions.Literal[log, warn]

Used mostly internally. It can use only warnings when logging. Make sense only when logging to console.

property filter: typing_extensions.Literal[ignore, once, always, error]

Define what to do with logs, that repeats.

Only first 100 symbols of message will be used if using once.

Do not affect warnings library. Use my_warnings module if you need that. Options: [“ignore”, “once”, “always”, “error”]

Defaults to: ‘once’

“error” means that application stop on log as on error.

property formatter_console_str: str
You can edit used formatter if you want. Just go to source of logging.Formatter to see

all possible options. This is only main string of formatter class (style=”{” is used). Message itself is formatted in format_str function. This is for formatter if logging to console.

Defaults to: “

{levelname}from {pathname}:{lineno} {funcName}{message}”

property formatter_file_str: str

You can edit used formatter if you want. Just go to source of logging.Formatter to see all possible options. This is only main string of formatter class (style=”{” is used). Message itself is formatted in format_str function. This is for formatter if logging to console.

Defaults to: “{asctime} {levelname} {filename}:{lineno}{message}”

property level: typing_extensions.Literal[DEBUG, INFO, WARNING, ERROR, CRITICAL]

Logs can be filtered out based on log severity.

Options: [“DEBUG”, “INFO”, “WARNING”, “ERROR”, “CRITICAL”]

Defaults to: “INFO”

property output: Optional[Union[str, Path]]

Whether log to file or to console. If None, nor console, nor file will be used (stream logs to a variable is still possible).

Options: [“console”, pathlib.Path, r”path/to/file”, None]

Defaults to: “console”

property stream: Any

Whether save all logs to stream (that stream can be variable).

Example: io.StringIO()

Defaults to: None

property to_list: Union[None, list[str]]

You can store all logs in list and then emit when you want.

Defaults to: None

mylogging.config_module.config = <mylogging.config_module.Config object>

You can configure mylogging from here. All variables has own docstrings.