izihawa-loglib 1.1.13__tar.gz → 1.1.15__tar.gz
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.
- {izihawa_loglib-1.1.13 → izihawa_loglib-1.1.15}/PKG-INFO +1 -1
- {izihawa_loglib-1.1.13 → izihawa_loglib-1.1.15}/izihawa_loglib/request_context.py +14 -1
- {izihawa_loglib-1.1.13 → izihawa_loglib-1.1.15}/pyproject.toml +1 -1
- {izihawa_loglib-1.1.13 → izihawa_loglib-1.1.15}/README.md +0 -0
- {izihawa_loglib-1.1.13 → izihawa_loglib-1.1.15}/izihawa_loglib/__init__.py +0 -0
- {izihawa_loglib-1.1.13 → izihawa_loglib-1.1.15}/izihawa_loglib/formatters.py +0 -0
- {izihawa_loglib-1.1.13 → izihawa_loglib-1.1.15}/izihawa_loglib/handlers.py +0 -0
@@ -18,7 +18,12 @@ class RequestContext:
|
|
18
18
|
)
|
19
19
|
|
20
20
|
def __getattr__(self, name: str) -> Any:
|
21
|
-
|
21
|
+
try:
|
22
|
+
return self.default_fields[name]
|
23
|
+
except KeyError:
|
24
|
+
classname = type(self).__name__
|
25
|
+
msg = f'{classname!r} object has no attribute {name!r}'
|
26
|
+
raise AttributeError(msg)
|
22
27
|
|
23
28
|
@staticmethod
|
24
29
|
def generate_request_id(length):
|
@@ -39,3 +44,11 @@ class RequestContext:
|
|
39
44
|
def error_log(self, e, level=logging.ERROR, **fields) -> None:
|
40
45
|
all_fields = {**self.default_fields, **fields}
|
41
46
|
error_log(e, level=level, **all_fields)
|
47
|
+
|
48
|
+
def to_default_headers(self) -> dict[str, Any]:
|
49
|
+
headers = {}
|
50
|
+
if request_id := self.default_fields.get("request_id"):
|
51
|
+
headers["X-Request-Id"] = request_id
|
52
|
+
if client_id := self.default_fields.get("client_id"):
|
53
|
+
headers["X-Client-Id"] = client_id
|
54
|
+
return headers
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|