izihawa-loglib 1.1.18__tar.gz → 1.1.20__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.18
3
+ Version: 1.1.20
4
4
  Summary: Izihawa log utilities
5
5
  Author: Pasha Podolsky
6
6
  Author-email: ppodolsky@me.com
@@ -37,8 +37,9 @@ class DefaultHttpFormatter(BaseFormatter):
37
37
  formatted_datetime = datetime.datetime.fromtimestamp(timestamp).strftime(
38
38
  DATETIME_FORMAT
39
39
  )
40
- client_ip = getattr(record, "client_ip", None)
40
+ real_ip = getattr(record, "real_ip", None)
41
41
  request_id = getattr(record, "request_id", None)
42
+ client_id = getattr(record, "client_id", None)
42
43
  method = getattr(record, "method", None)
43
44
  path = getattr(record, "path", None)
44
45
 
@@ -49,10 +50,12 @@ class DefaultHttpFormatter(BaseFormatter):
49
50
  process=os.getpid(),
50
51
  )
51
52
 
52
- if client_ip:
53
- log_record["client_ip"] = client_ip
53
+ if real_ip:
54
+ log_record["real_ip"] = real_ip
54
55
  if request_id:
55
56
  log_record["request_id"] = request_id
57
+ if client_id:
58
+ log_record["client_id"] = client_id
56
59
  if method:
57
60
  log_record["method"] = method
58
61
  if path:
@@ -9,7 +9,8 @@ class RequestContext:
9
9
  request_id_length: int = 12
10
10
 
11
11
  def __init__(
12
- self, **kwargs: Any,
12
+ self,
13
+ **kwargs: Any,
13
14
  ):
14
15
  self.default_fields = kwargs
15
16
  if not self.default_fields.get("request_id"):
@@ -22,7 +23,7 @@ class RequestContext:
22
23
  return self.default_fields[name]
23
24
  except KeyError:
24
25
  classname = type(self).__name__
25
- msg = f'{classname!r} object has no attribute {name!r}'
26
+ msg = f"{classname!r} object has no attribute {name!r}"
26
27
  raise AttributeError(msg)
27
28
 
28
29
  @staticmethod
@@ -44,11 +45,3 @@ class RequestContext:
44
45
  def error_log(self, e, level=logging.ERROR, **fields) -> None:
45
46
  all_fields = {**self.default_fields, **fields}
46
47
  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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "izihawa_loglib"
3
- version = "1.1.18"
3
+ version = "1.1.20"
4
4
  description = "Izihawa log utilities"
5
5
  authors = ["Pasha Podolsky <ppodolsky@me.com>"]
6
6
  readme = "README.md"