YAML Validate

Validate logging.config yaml files.

Available as an:

  • ep

  • via pre-commit

See also

Custom filters use case

logging.config [spec]

strictyaml.compound_types

Limitations

  1. logging.handlers.SMTPHandler arg secure takes:

    • None

    • empty tuple

    • tuple[str]

    • tuple[str, str]

Actual: tuple[] or tuple[typing.Any, …]

So can’t prevent len(Sequence) > 2

  1. logging.handlers.TimedRotatingFileHandler arg asTime

strictyaml has no support for datetime.time

Module private variables

logging_strict.logging_yaml_validate.__all__: tuple[str, str] = ("schema_logging_config", "validate_yaml_dirty")

Module exports

Module objects

logging_strict.logging_yaml_validate.validate_yaml_dirty(yaml_snippet, schema=schema_logging_config)

This designed with the intent to verify logging.config yaml

In logging.config docs, all examples shown contain YAML flow_style.

YAML flow style (incorrect)

somelist: [item0, item1]

Without flow style (Correct)

somelist:
  - item0
  - item1

Eventhough it’s easy to fix the yaml, logging.config.dictConfig() will accept the non-fixed yaml

Reluctantly … allow flow style

world+dog

Parameters:
Returns:

YAML object. Pass this to each worker

Return type:

strictyaml.representation.YAML | None

See also

Modern way of dealing with Traceback

class logging_strict.logging_yaml_validate.schema_logging_config

strictyaml schema for logging.config yaml files