Bases: BaseSettings
Data.Rentgen backend logging Settings.
Examples
Using json preset:
.. code-block:: bash
DATA_RENTGEN__LOGGING__SETUP=True
DATA_RENTGEN__LOGGING__PRESET=json
Passing custom logging config file:
.. code-block:: bash
DATA_RENTGEN__LOGGING__SETUP=True
DATA_RENTGEN__LOGGING__CUSTOM_CONFIG_PATH=/some/logging.yml
Setup logging in some other way, e.g. using uvicorn args <https://www.uvicorn.org/settings/#logging>_:
.. code-block:: bash
$ export DATA_RENTGEN__LOGGING__SETUP=False
$ python -m data_rentgen.server --log-level debug
Source code in data_rentgen/logging/settings.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 | class LoggingSettings(BaseSettings):
"""Data.Rentgen backend logging Settings.
Examples
--------
Using ``json`` preset:
.. code-block:: bash
DATA_RENTGEN__LOGGING__SETUP=True
DATA_RENTGEN__LOGGING__PRESET=json
Passing custom logging config file:
.. code-block:: bash
DATA_RENTGEN__LOGGING__SETUP=True
DATA_RENTGEN__LOGGING__CUSTOM_CONFIG_PATH=/some/logging.yml
Setup logging in some other way, e.g. using `uvicorn args <https://www.uvicorn.org/settings/#logging>`_:
.. code-block:: bash
$ export DATA_RENTGEN__LOGGING__SETUP=False
$ python -m data_rentgen.server --log-level debug
"""
setup: bool = Field(
default=True,
description="If ``True``, setup logging during application start",
)
preset: Literal["json", "plain", "colored"] = Field(
default="plain",
description=textwrap.dedent(
"""
Name of logging preset to use.
There are few logging presets bundled to ``data-rentgen[server]`` package:
.. dropdown:: ``plain`` preset
This preset is recommended to use in environment which do not support colored output,
e.g. CI jobs
.. literalinclude:: ../../../../data_rentgen/logging/presets/plain.yml
.. dropdown:: ``colored`` preset
This preset is recommended to use in development environment,
as it simplifies debugging. Each log record is output with color specific for a log level
.. literalinclude:: ../../../../data_rentgen/logging/presets/colored.yml
.. dropdown:: ``json`` preset
This preset is recommended to use in production environment,
as it allows to avoid writing complex log parsing configs. Each log record is output as JSON line
.. literalinclude:: ../../../../data_rentgen/logging/presets/json.yml
""",
),
)
custom_config_path: Path | None = Field(
default=None,
description=textwrap.dedent(
"""
Path to custom logging configuration file. If set, overrides :obj:`~preset` value.
File content should be in YAML format and conform
`logging.dictConfig <https://docs.python.org/3/library/logging.config.html#logging-config-dictschema>`_.
""",
),
)
model_config = SettingsConfigDict(env_prefix="DATA_RENTGEN__LOGGING__", env_nested_delimiter="__", extra="forbid")
|
setup = Field(default=True, description='If ``True``, setup logging during application start')
class-attribute
instance-attribute
preset = Field(default='plain', description=(textwrap.dedent('\n Name of logging preset to use.\n\n There are few logging presets bundled to ``data-rentgen[server]`` package:\n\n .. dropdown:: ``plain`` preset\n\n This preset is recommended to use in environment which do not support colored output,\n e.g. CI jobs\n\n .. literalinclude:: ../../../../data_rentgen/logging/presets/plain.yml\n\n .. dropdown:: ``colored`` preset\n\n This preset is recommended to use in development environment,\n as it simplifies debugging. Each log record is output with color specific for a log level\n\n .. literalinclude:: ../../../../data_rentgen/logging/presets/colored.yml\n\n .. dropdown:: ``json`` preset\n\n This preset is recommended to use in production environment,\n as it allows to avoid writing complex log parsing configs. Each log record is output as JSON line\n\n .. literalinclude:: ../../../../data_rentgen/logging/presets/json.yml\n ')))
class-attribute
instance-attribute