logging-strict 1.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. logging_strict/__init__.py +147 -0
  2. logging_strict/__init__.pyi +35 -0
  3. logging_strict/_version.py +16 -0
  4. logging_strict/_version.pyi +6 -0
  5. logging_strict/bad_idea/__init__.py +0 -0
  6. logging_strict/bad_idea/folder0/__init__.py +0 -0
  7. logging_strict/bad_idea/folder0/mp_1_shared.worker.logging.config.yaml +1 -0
  8. logging_strict/bad_idea/folder1/__init__.py +0 -0
  9. logging_strict/bad_idea/folder1/mp_1_shared.worker.logging.config.yaml +1 -0
  10. logging_strict/configs/__init__.py +0 -0
  11. logging_strict/configs/mp_1_asz.worker.logging.config.yaml +27 -0
  12. logging_strict/configs/textual_1_asz.app.logging.config.yaml +24 -0
  13. logging_strict/constants.py +190 -0
  14. logging_strict/constants.pyi +38 -0
  15. logging_strict/ep_validate_yaml.py +344 -0
  16. logging_strict/ep_validate_yaml.pyi +4 -0
  17. logging_strict/exceptions.py +98 -0
  18. logging_strict/exceptions.pyi +22 -0
  19. logging_strict/logging_api.py +1091 -0
  20. logging_strict/logging_api.pyi +102 -0
  21. logging_strict/logging_api_test.py +105 -0
  22. logging_strict/logging_api_test.pyi +38 -0
  23. logging_strict/logging_strict.yml +27 -0
  24. logging_strict/logging_yaml_abc.py +595 -0
  25. logging_strict/logging_yaml_abc.pyi +79 -0
  26. logging_strict/logging_yaml_validate.py +295 -0
  27. logging_strict/logging_yaml_validate.pyi +30 -0
  28. logging_strict/py.typed +0 -0
  29. logging_strict/register_config.py +650 -0
  30. logging_strict/register_config.pyi +63 -0
  31. logging_strict/tech_niques/__init__.py +119 -0
  32. logging_strict/tech_niques/__init__.pyi +29 -0
  33. logging_strict/tech_niques/context_locals.py +324 -0
  34. logging_strict/tech_niques/context_locals.pyi +36 -0
  35. logging_strict/tech_niques/coverage_misbehaves.py +43 -0
  36. logging_strict/tech_niques/coverage_misbehaves.pyi +1 -0
  37. logging_strict/tech_niques/logger_redirect.py +171 -0
  38. logging_strict/tech_niques/logger_redirect.pyi +26 -0
  39. logging_strict/tech_niques/logging_capture.py +779 -0
  40. logging_strict/tech_niques/logging_capture.pyi +60 -0
  41. logging_strict/tech_niques/stream_capture.py +108 -0
  42. logging_strict/tech_niques/stream_capture.pyi +22 -0
  43. logging_strict/util/__init__.py +0 -0
  44. logging_strict/util/check_logging.py +251 -0
  45. logging_strict/util/check_logging.pyi +24 -0
  46. logging_strict/util/check_type.py +258 -0
  47. logging_strict/util/check_type.pyi +20 -0
  48. logging_strict/util/package_resource.py +1701 -0
  49. logging_strict/util/package_resource.pyi +119 -0
  50. logging_strict/util/pep518_read.py +228 -0
  51. logging_strict/util/pep518_read.pyi +19 -0
  52. logging_strict/util/util_root.py +455 -0
  53. logging_strict/util/util_root.pyi +55 -0
  54. logging_strict/util/xdg_folder.py +385 -0
  55. logging_strict/util/xdg_folder.pyi +56 -0
  56. logging_strict/version_semantic.py +331 -0
  57. logging_strict/version_semantic.pyi +16 -0
  58. logging_strict-1.5.0.dist-info/LICENSE.txt +177 -0
  59. logging_strict-1.5.0.dist-info/METADATA +921 -0
  60. logging_strict-1.5.0.dist-info/NOTICE.txt +13 -0
  61. logging_strict-1.5.0.dist-info/RECORD +64 -0
  62. logging_strict-1.5.0.dist-info/WHEEL +5 -0
  63. logging_strict-1.5.0.dist-info/entry_points.txt +2 -0
  64. logging_strict-1.5.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,147 @@
1
+ """
2
+ UI
3
+ ---
4
+
5
+ :ref:`getting_started/usage:app`
6
+
7
+ Within UI process, call both:
8
+
9
+ - LoggingState
10
+
11
+ - ui_yaml_curated or setup_ui_other
12
+
13
+ worker process
14
+ ---------------
15
+
16
+ :ref:`getting_started/usage:worker`
17
+
18
+ Step 1
19
+ ~~~~~~~
20
+
21
+ Within worker entrypoint call either:
22
+
23
+ - worker_yaml_curated or setup_worker_other
24
+
25
+ Then pass str_yaml to the worker process
26
+
27
+ Step 2
28
+ ~~~~~~~
29
+
30
+ Within worker process call
31
+
32
+ - setup_logging_yaml
33
+
34
+ Constants
35
+ ----------
36
+
37
+ - LoggingConfigCategory
38
+ :ref:`[constant docs] <code/constants/constants_general:top>`
39
+
40
+ tl;dr; ^^ won't need this ^^
41
+
42
+ Process categories Enum. Iterate over the Enum values, using class
43
+ method, `categories`.
44
+
45
+ `strict_logging` public methods are convenience functions for class,
46
+ `strict_logging.logging_api.LoggingConfigYaml`. If LoggingConfigYaml
47
+ used directly, choose one of the LoggingConfigCategory values to
48
+ pass as param, category.
49
+
50
+ Values: LoggingConfigCategory.UI or LoggingConfigCategory.WORKER
51
+
52
+ Corresponds to 'app' and 'worker'
53
+
54
+ Types
55
+ ------
56
+
57
+ - LoggingYamlType
58
+ :ref:`[type docs] <code/yaml/logging_yaml_abc:top>`
59
+
60
+ tl;dr; ^^ won't need this ^^
61
+
62
+ Useful only during strict type checking. class LoggingConfigYaml
63
+ implements LoggingYamlType interface and is a direct subclass
64
+
65
+ e.g. ``type[LoggingYamlType]``
66
+
67
+ Exceptions
68
+ -----------
69
+
70
+ :ref:`[exc docs] <code/constants/exceptions:exceptions>`
71
+
72
+ - LoggingStrictError
73
+
74
+ logging_strict catch all Exception. Base type of other exceptions.
75
+ Implements ValueError
76
+
77
+ Provided just for completeness. Not intended for use
78
+
79
+ - LoggingStrictPackageNameRequired
80
+
81
+ :abbr:`ep (entrypoint)` requires package name
82
+
83
+ Corresponding exit code -- 6
84
+
85
+ - LoggingStrictPackageStartFolderNameRequired
86
+
87
+ :abbr:`ep (entrypoint)` requires package start folder name
88
+
89
+ In logging-strict this is ``configs``. Normally its ``data``. But it can be anything
90
+
91
+ Corresponding exit code -- 7
92
+
93
+ - LoggingStrictProcessCategoryRequired
94
+
95
+ Applicable only during extract or setup, not during validation
96
+
97
+ Category required. Either:
98
+
99
+ LoggingConfigCategory.UI.value or LoggingConfigCategory.WORKER.value
100
+
101
+ Which corresponds to "app" or "worker"
102
+
103
+ - LoggingStrictGenreRequired
104
+
105
+ Applicable only during extract or setup, not during validation
106
+
107
+ UI framework terse name or worker implementation characteristic
108
+
109
+ e.g. textual, rich, :abbr:`mp (multiprocessing)` or :abbr:`mq (rabbitmq)`
110
+
111
+ """
112
+
113
+ from .constants import LoggingConfigCategory
114
+ from .exceptions import (
115
+ LoggingStrictError,
116
+ LoggingStrictGenreRequired,
117
+ LoggingStrictPackageNameRequired,
118
+ LoggingStrictPackageStartFolderNameRequired,
119
+ LoggingStrictProcessCategoryRequired,
120
+ )
121
+ from .logging_api import (
122
+ LoggingState,
123
+ setup_ui_other,
124
+ setup_worker_other,
125
+ ui_yaml_curated,
126
+ worker_yaml_curated,
127
+ )
128
+ from .logging_yaml_abc import (
129
+ LoggingYamlType,
130
+ setup_logging_yaml,
131
+ )
132
+
133
+ __all__ = (
134
+ "LoggingConfigCategory",
135
+ "LoggingState",
136
+ "LoggingYamlType",
137
+ "setup_ui_other",
138
+ "ui_yaml_curated",
139
+ "setup_worker_other",
140
+ "worker_yaml_curated",
141
+ "setup_logging_yaml",
142
+ "LoggingStrictError",
143
+ "LoggingStrictPackageNameRequired",
144
+ "LoggingStrictPackageStartFolderNameRequired",
145
+ "LoggingStrictProcessCategoryRequired",
146
+ "LoggingStrictGenreRequired",
147
+ )
@@ -0,0 +1,35 @@
1
+ from .constants import LoggingConfigCategory
2
+ from .exceptions import (
3
+ LoggingStrictError,
4
+ LoggingStrictGenreRequired,
5
+ LoggingStrictPackageNameRequired,
6
+ LoggingStrictPackageStartFolderNameRequired,
7
+ LoggingStrictProcessCategoryRequired,
8
+ )
9
+ from .logging_api import (
10
+ LoggingState,
11
+ setup_ui_other,
12
+ setup_worker_other,
13
+ ui_yaml_curated,
14
+ worker_yaml_curated,
15
+ )
16
+ from .logging_yaml_abc import (
17
+ LoggingYamlType,
18
+ setup_logging_yaml,
19
+ )
20
+
21
+ __all__ = (
22
+ "LoggingConfigCategory",
23
+ "LoggingState",
24
+ "LoggingYamlType",
25
+ "setup_ui_other",
26
+ "ui_yaml_curated",
27
+ "setup_worker_other",
28
+ "worker_yaml_curated",
29
+ "setup_logging_yaml",
30
+ "LoggingStrictError",
31
+ "LoggingStrictPackageNameRequired",
32
+ "LoggingStrictPackageStartFolderNameRequired",
33
+ "LoggingStrictProcessCategoryRequired",
34
+ "LoggingStrictGenreRequired",
35
+ )
@@ -0,0 +1,16 @@
1
+ # file generated by setuptools_scm
2
+ # don't change, don't track in version control
3
+ TYPE_CHECKING = False
4
+ if TYPE_CHECKING:
5
+ from typing import Tuple, Union
6
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
7
+ else:
8
+ VERSION_TUPLE = object
9
+
10
+ version: str
11
+ __version__: str
12
+ __version_tuple__: VERSION_TUPLE
13
+ version_tuple: VERSION_TUPLE
14
+
15
+ __version__ = version = '1.5.0'
16
+ __version_tuple__ = version_tuple = (1, 5, 0)
@@ -0,0 +1,6 @@
1
+ from typing import Final
2
+
3
+ version: Final[str]
4
+ __version__: Final[str]
5
+ __version_tuple__: Final[tuple[int | str, ...]]
6
+ version_tuple: Final[tuple[int | str, ...]]
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,27 @@
1
+ version: 1
2
+ disable_existing_loggers: false
3
+ raise_exceptions: true
4
+ formatters:
5
+ detailed:
6
+ class: logging.Formatter
7
+ format: '%(asctime)s %(name)-15s %(levelname)-8s %(processName)-10s %(message)s'
8
+ simple:
9
+ class: logging.Formatter
10
+ format: '%(name)-15s %(levelname)-8s %(processName)-10s %(message)s'
11
+ handlers:
12
+ console_worker:
13
+ class: logging.StreamHandler
14
+ formatter: simple
15
+ level: WARNING
16
+ loggers:
17
+ package_name:
18
+ handlers: [console_worker]
19
+ propagate: true
20
+ level: INFO
21
+ asyncio:
22
+ handlers: [console_worker]
23
+ propagate: true
24
+ level: ERROR
25
+ root:
26
+ handlers: [console_worker]
27
+ level: ERROR
@@ -0,0 +1,24 @@
1
+ version: 1
2
+ disable_existing_loggers: false
3
+ raise_exceptions: true
4
+ formatters:
5
+ simple:
6
+ class: logging.Formatter
7
+ format: '%(levelname)s %(module)s %(funcName)s: %(lineno)d: %(message)s'
8
+ handlers:
9
+ console_ui:
10
+ '()': ext://textual.logging.TextualHandler
11
+ formatter: simple
12
+ level: WARNING
13
+ loggers:
14
+ package_name:
15
+ handlers: [console_ui]
16
+ propagate: true
17
+ level: INFO
18
+ asyncio:
19
+ handlers: [console_ui]
20
+ propagate: true
21
+ level: ERROR
22
+ root:
23
+ handlers: [console_ui]
24
+ level: ERROR
@@ -0,0 +1,190 @@
1
+ """
2
+ .. moduleauthor:: Dave Faulkmore <https://mastodon.social/@msftcangoblowme>
3
+
4
+ Seperate constants out so independent of any dependencies
5
+
6
+ **Module private variables**
7
+
8
+ .. py:data:: _map_release
9
+ :type: types.MappingProxyType
10
+ :value: types.MappingProxyType({"alpha": "a", "beta": "b", "candidate": "rc"})
11
+
12
+ Mapping of release levels. So can gracefully go back and forth
13
+
14
+ .. py:data:: __all__
15
+ :type: tuple[str, str, str, str, str, str, str, str]
16
+ :value: ("g_app_name", "__version_app", "LoggingConfigCategory", \
17
+ "PREFIX_DEFAULT", "LOG_FORMAT", "FALLBACK_LEVEL", "sanitize_tag", \
18
+ "get_version")
19
+
20
+ Module exports
21
+
22
+ **Module objects**
23
+
24
+ .. py:data:: g_app_name
25
+ :type: str
26
+ :value: "logging_strict"
27
+
28
+ App name. No hyphens. Lowercase. Not project name which can contain
29
+ hyphen
30
+
31
+ .. py:data:: PREFIX_DEFAULT
32
+ :type: str
33
+ :value: "test_"
34
+
35
+ unittest module default file name prefix
36
+
37
+ .. py:data:: LOG_FORMAT
38
+ :type: str
39
+ :value: "%(levelname)s %(module)s %(funcName)s: %(lineno)d: %(message)s"
40
+
41
+ :py:mod:`logging` handlers contain formatters, which require a format
42
+ str. Especially pertinent to unittests
43
+
44
+ .. py:data:: FALLBACK_LEVEL
45
+ :type: str
46
+ :value: "DEBUG"
47
+
48
+ Fallback logging level, if provided level is an unsupported type, None, or empty str.
49
+ So by default, this logging level, captures all.
50
+
51
+ .. py:data:: LOG_FMT_DETAILED
52
+ :type: str
53
+ :value: "%(asctime)s %(name)-15s %(levelname)-8s %(processName)-10s %(message)s"
54
+
55
+ Detailed log message format. Notably includes: time, logger
56
+ (worker) name, and process name
57
+
58
+ .. py:data:: LOG_FMT_SIMPLE
59
+ :type: str
60
+ :value: "%(name)-15s %(levelname)-8s %(processName)-10s %(message)s"
61
+
62
+ Terse log message format. Notably includes: logger (worker) name and process name
63
+
64
+ .. py:data:: LOG_LEVEL_WORKER
65
+ :type: str
66
+ :value: "INFO"
67
+
68
+ Show messages from :py:data:`logging.INFO` and higher
69
+
70
+ .. seealso::
71
+
72
+ - :py:meth:`coverage.control.Coverage.start`
73
+
74
+ - :py:mod:`coverage.multiproc`
75
+
76
+
77
+ .. py:data:: version_info
78
+ :type: tuple[int, int, int, str, int]
79
+
80
+ Same semantics as :py:data:`sys.version_info`
81
+
82
+ .. py:data:: _dev
83
+ :type: int
84
+
85
+ .devN suffix, if any
86
+
87
+ .. py:data:: __version__
88
+ :type: str
89
+
90
+ Semantic versioning.
91
+
92
+ :py:mod:`setuptools_scm` semantic versioning in: logging_strict._version.__version__
93
+
94
+ .. code-block:: shell
95
+
96
+ python igor.py bump_version
97
+
98
+ ``igor.py`` updates this file, writing both version_info and _dev
99
+
100
+ Dynamically generated by :py:mod:`setuptools_scm`
101
+ if no patch or no tags at all SemVer will break.
102
+
103
+ e.g. 2.1.devX instead of 2.0.1.devX
104
+
105
+ Always include patch and ensure at least one tagged version
106
+
107
+ .. seealso::
108
+
109
+ :py:mod:`setuptools_scm`
110
+
111
+
112
+ """
113
+
114
+ from __future__ import annotations
115
+
116
+ import logging # noqa: F401 used by sphinx
117
+ from enum import Enum
118
+ from typing import Any # noqa: F401 used by sphinx
119
+
120
+ from ._version import __version__
121
+ from .version_semantic import (
122
+ readthedocs_url,
123
+ sanitize_tag,
124
+ )
125
+
126
+ __all__ = (
127
+ "g_app_name",
128
+ "__version_app",
129
+ "__url__",
130
+ "PREFIX_DEFAULT",
131
+ "LoggingConfigCategory",
132
+ "LOG_FORMAT",
133
+ "FALLBACK_LEVEL",
134
+ )
135
+
136
+ g_app_name = "logging_strict"
137
+
138
+ PREFIX_DEFAULT = "test_"
139
+
140
+
141
+ def enum_map_func_get_value(enum_item):
142
+ """func for use with Python built-in :py:func:`map`, to get the
143
+ value of an Enum item
144
+
145
+ :param enum_item: Enum subclass item. Get the Enum item value
146
+ :type enum_item: type[enum.Enum]
147
+ :returns: Enum item value. Can be anything but usually a str or int
148
+ :rtype: typing.Any
149
+ """
150
+ return enum_item.value
151
+
152
+
153
+ class LoggingConfigCategory(Enum):
154
+ """logging.config yaml process categories
155
+
156
+ Public API
157
+
158
+ .. code-block:: text
159
+
160
+ from logging_strict import LoggingConfigCategory
161
+
162
+ """
163
+
164
+ WORKER = "worker"
165
+ UI = "app"
166
+
167
+ @classmethod
168
+ def categories(cls):
169
+ """Get Enum items' value
170
+
171
+ :returns: In this case, Enum values holds str
172
+ :rtype: collections.abc.Iterator[str]
173
+ """
174
+ values = cls._member_map_.values()
175
+ yield from map(enum_map_func_get_value, values)
176
+
177
+
178
+ LOG_FORMAT = "%(levelname)s %(module)s %(funcName)s: %(lineno)d: %(message)s"
179
+ FALLBACK_LEVEL = logging.getLevelName(logging.DEBUG)
180
+
181
+ # Thread pool worker
182
+ LOG_FMT_DETAILED = (
183
+ "%(asctime)s %(name)-15s %(levelname)-8s %(processName)-10s %(message)s"
184
+ )
185
+ LOG_FMT_SIMPLE = "%(name)-15s %(levelname)-8s %(processName)-10s %(message)s"
186
+ LOG_LEVEL_WORKER = "INFO"
187
+
188
+ # Removes epoch and local. Fixes version
189
+ __version_app = sanitize_tag(__version__)
190
+ __url__ = readthedocs_url(g_app_name, ver_=__version__)
@@ -0,0 +1,38 @@
1
+ from collections.abc import Iterator
2
+ from enum import Enum
3
+ from typing import (
4
+ Any,
5
+ Final,
6
+ )
7
+
8
+ __all__ = (
9
+ "g_app_name",
10
+ "__version_app",
11
+ "__url__",
12
+ "PREFIX_DEFAULT",
13
+ "LoggingConfigCategory",
14
+ "LOG_FORMAT",
15
+ "FALLBACK_LEVEL",
16
+ )
17
+
18
+ g_app_name: Final[str]
19
+ PREFIX_DEFAULT: Final[str]
20
+
21
+ def enum_map_func_get_value(enum_item: type[Enum]) -> Any: ...
22
+
23
+ class LoggingConfigCategory(Enum):
24
+ WORKER = "worker"
25
+ UI = "app"
26
+
27
+ @classmethod
28
+ def categories(cls) -> Iterator[str]: ...
29
+
30
+ LOG_FORMAT: Final[str]
31
+ FALLBACK_LEVEL: Final[str]
32
+
33
+ LOG_FMT_DETAILED: Final[str]
34
+ LOG_FMT_SIMPLE: Final[str]
35
+ LOG_LEVEL_WORKER: Final[str]
36
+
37
+ __version_app: Final[str]
38
+ __url__: Final[str]