demessaging.config.logging module

Configuration module for logging in DASF.

This module defines the configuration class for logging within the DASF Framework.

Classes:

LoggingConfig([_case_sensitive, ...])

Configuration for logging.

class demessaging.config.logging.LoggingConfig(_case_sensitive: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_parse_none_str: str | None = None, _secrets_dir: str | Path | None = None, *, config_file: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/dasf/checkouts/latest/demessaging/config/logging.yaml'), level: int | None = None, logfile: Path | None = None, config_overrides: Dict | None = None, merge_config: bool = False)[source]

Bases: BaseSettings

Configuration for logging.

Parameters:
  • config_file (pathlib.Path) – Path to the logging configuration.

  • level (Optional[Annotated[int, Gt(gt=0)]]) – Level for the logger. Setting this will override any levels specified in the logging config file. The lower the value, the more verbose the logging. Typical levels are 10 (DEBUG), 20 (INFO), 30 (WARNING), 40 (ERROR) and 50 (CRITICAL).

  • logfile (Optional[pathlib.Path]) – A path to use for logging. If this is specified, we will add a RotatingFileHandler that loggs to the given path and add this handler to any logger in the logging config.

  • config_overrides (Optional[Dict]) – A dictionary to override the configuration specified in the logging configuration file.

  • merge_config (bool) – If this is True, the specified logging configuration file will be merged with the default one at /home/docs/checkouts/readthedocs.org/user_builds/dasf/checkouts/latest/demessaging/config/logging.yaml

Attributes:

config_dict

Configuration dictionary for the logging.

config_file

config_overrides

level

logfile

merge_config

model_computed_fields

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

Methods:

configure_logging()

Configure the loggers based upon the given config.

property config_dict: Dict

Configuration dictionary for the logging.

config_file: Path
config_overrides: Dict | None
configure_logging()[source]

Configure the loggers based upon the given config.

level: int | None
logfile: Path | None
merge_config: bool
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[SettingsConfigDict] = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'env_file': None, 'env_file_encoding': None, 'env_ignore_empty': False, 'env_nested_delimiter': None, 'env_parse_none_str': None, 'env_prefix': 'de_logging_', 'extra': 'forbid', 'json_file': None, 'json_file_encoding': None, 'protected_namespaces': ('model_', 'settings_'), 'secrets_dir': None, 'toml_file': None, 'validate_default': True, 'yaml_file': None, 'yaml_file_encoding': None}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'config_file': FieldInfo(annotation=Path, required=False, default=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/dasf/checkouts/latest/demessaging/config/logging.yaml'), description='Path to the logging configuration.', metadata=[PathType(path_type='file')]), 'config_overrides': FieldInfo(annotation=Union[Dict, NoneType], required=False, default=None, description='A dictionary to override the configuration specified in the logging configuration file.'), 'level': FieldInfo(annotation=Union[Annotated[int, Gt], NoneType], required=False, default=None, description='Level for the logger. Setting this will override any levels specified in the logging config file. The lower the value, the more verbose the logging. Typical levels are 10 (DEBUG), 20 (INFO), 30 (WARNING), 40 (ERROR) and 50 (CRITICAL).'), 'logfile': FieldInfo(annotation=Union[Path, NoneType], required=False, default=None, description='A path to use for logging. If this is specified, we will add a RotatingFileHandler that loggs to the given path and add this handler to any logger in the logging config.'), 'merge_config': FieldInfo(annotation=bool, required=False, default=False, description='If this is True, the specified logging configuration file will be merged with the default one at /home/docs/checkouts/readthedocs.org/user_builds/dasf/checkouts/latest/demessaging/config/logging.yaml')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.