qilisdk.logging
config.py
Attributes
Classes
Configuration for a single Loguru sink. |
|
Configuration for intercepting a stdlib logging library. |
|
Pydantic settings for Loguru configuration loaded from YAML or JSON. |
|
Redirect stdlib 'logging' records to Loguru, optionally filtering by name_prefix. |
Functions
|
Configure QiliSDK logging. This is the main entry point for controlling log output. |
Module Contents
- LEVEL_ICONS: dict[str, str][font]
- class SinkConfig(/, **data: Any)[font]
Bases:
pydantic.BaseModelConfiguration for a single Loguru sink.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- sink: str | pathlib.Path[font]
- level: str = 'INFO'[font]
- format: str | None = None[font]
- filter: str | dict[str, str] | None = None[font]
- colorize: bool = False[font]
- enqueue: bool = False[font]
- rotation: str | None = None[font]
- serialize: bool = False[font]
- class InterceptLibraryConfig(/, **data: Any)[font]
Bases:
pydantic.BaseModelConfiguration for intercepting a stdlib logging library.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- name: str[font]
- level: str = 'ERROR'[font]
- class LoggingSettings(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_prefix_target: pydantic_settings.sources.EnvPrefixTarget | None = None, _env_file: pydantic_settings.sources.DotenvType | None = ENV_FILE_SENTINEL, _env_file_encoding: str | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: pydantic_settings.sources.CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_show_env_vars: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | Literal['dual', 'toggle'] | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: collections.abc.Mapping[str, str | list[str]] | None = None, _secrets_dir: pydantic_settings.sources.PathType | None = None, _build_sources: tuple[tuple[pydantic_settings.sources.PydanticBaseSettingsSource, ...], dict[str, Any]] | None = None, **values: Any)[font]
Bases:
pydantic_settings.BaseSettingsPydantic settings for Loguru configuration loaded from YAML or JSON.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- sinks: list[SinkConfig] = [][font]
- intercept_libraries: list[InterceptLibraryConfig] = [][font]
- classmethod load(path: str | pathlib.Path) LoggingSettings[font]
- class InterceptHandler(level=NOTSET)[font]
Bases:
logging.HandlerRedirect stdlib “logging” records to Loguru, optionally filtering by name_prefix.
Initializes the instance - basically setting the formatter to None and the filter list to empty.
- emit(record: logging.LogRecord) None[font]
Do whatever it takes to actually log the specified logging record.
This version is intended to be implemented by subclasses and so raises a NotImplementedError.
- configure_logging(level: str | None = None, filename: str | pathlib.Path | None = None, stderr: bool = True) None[font]
Configure QiliSDK logging. This is the main entry point for controlling log output. Output can be sent to the console, to a file, or both.
- Paràmetres:
level (
str | None) – If provided, override the level of every sink with this value (e.g., «TRACE», «DEBUG», «INFO», «WARNING», «ERROR», «CRITICAL»). All other sink options (format, filter, colorize, …) are preserved. IfNone, each sink uses its configured level.filename (
str | Path | None) – If provided, write logs to this file (in plain, non-colored text using the configured format). IfNone, no file output is produced.stderr (
bool) – IfTrue(the default), log to the console sinks defined in the configuration. Set toFalseto disable console output (for example, to log only tofilename).
Exemple
from qilisdk import configure_logging configure_logging(level="DEBUG") # console only, more verbose configure_logging(level="TRACE", filename="run.log") # console and file configure_logging(filename="run.log", stderr=False) # file only