izihawa-loglib 1.1.8__tar.gz → 1.1.9__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: izihawa_loglib
3
- Version: 1.1.8
3
+ Version: 1.1.9
4
4
  Summary: Izihawa log utilities
5
5
  Author: Pasha Podolsky
6
6
  Author-email: ppodolsky@me.com
@@ -1,4 +1,5 @@
1
1
  import logging
2
+ from typing import Any
2
3
 
3
4
  from izihawa_loglib import error_log
4
5
  from izihawa_utils.random import generate_request_id
@@ -7,16 +8,20 @@ from izihawa_utils.random import generate_request_id
7
8
  class RequestContext:
8
9
  request_id_length: int = 12
9
10
 
10
- def __init__(self, request_id: str | None = None, client_id: str | None = None, **kwargs):
11
- self.request_id = request_id or RequestContext.generate_request_id(
12
- self.request_id_length
13
- )
14
- self.client_id = client_id
15
- self.default_fields = {
16
- "request_id": self.request_id,
17
- "client_id": self.client_id,
18
- **kwargs,
19
- }
11
+ def __init__(
12
+ self, **kwargs: dict[str, Any],
13
+ ):
14
+ self.default_fields = kwargs
15
+ if "request_id" not in self.default_fields:
16
+ self.default_fields["request_id"] = RequestContext.generate_request_id(
17
+ self.request_id_length
18
+ )
19
+
20
+ def __getattr__(self, name: str) -> Any:
21
+ return self.default_fields[name]
22
+
23
+ def __setattr__(self, key: str, value: Any):
24
+ self.default_fields[key] = value
20
25
 
21
26
  @staticmethod
22
27
  def generate_request_id(length):
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "izihawa_loglib"
3
- version = "1.1.8"
3
+ version = "1.1.9"
4
4
  description = "Izihawa log utilities"
5
5
  authors = ["Pasha Podolsky <ppodolsky@me.com>"]
6
6
  readme = "README.md"
File without changes