@@ -15,9 +15,55 @@ def __init__(
15
15
use_datetime_directive : bool = False ,
16
16
log_record_order : list [str ] | None = None ,
17
17
utc : bool = False ,
18
- use_rfc3339 : bool = True ,
18
+ use_rfc3339 : bool = True , # NOTE: The only change from our base formatter
19
19
** kwargs ,
20
20
):
21
+ """Datadog formatter to comply with Datadog log parsing
22
+
23
+ Changes compared to the default Logger Formatter:
24
+
25
+ - timestamp format to use RFC3339 e.g., "2023-05-01T15:34:26.841+0200"
26
+
27
+
28
+ Parameters
29
+ ----------
30
+ log_record_order : list[str] | None, optional
31
+ _description_, by default None
32
+
33
+ Parameters
34
+ ----------
35
+ json_serializer : Callable, optional
36
+ function to serialize `obj` to a JSON formatted `str`, by default json.dumps
37
+ json_deserializer : Callable, optional
38
+ function to deserialize `str`, `bytes`, bytearray` containing a JSON document to a Python `obj`,
39
+ by default json.loads
40
+ json_default : Callable, optional
41
+ function to coerce unserializable values, by default str
42
+
43
+ Only used when no custom JSON encoder is set
44
+
45
+ datefmt : str, optional
46
+ String directives (strftime) to format log timestamp.
47
+
48
+ See https://docs.python.org/3/library/time.html#time.strftime or
49
+ use_datetime_directive: str, optional
50
+ Interpret `datefmt` as a format string for `datetime.datetime.strftime`, rather than
51
+ `time.strftime` - Only useful when used alongside `datefmt`.
52
+
53
+ See https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior . This
54
+ also supports a custom %F directive for milliseconds.
55
+
56
+ log_record_order : list, optional
57
+ set order of log keys when logging, by default ["level", "location", "message", "timestamp"]
58
+
59
+ utc : bool, optional
60
+ set logging timestamp to UTC, by default False to continue to use local time as per stdlib
61
+ use_rfc3339: bool, optional
62
+ Whether to use a popular dateformat that complies with both RFC3339 and ISO8601.
63
+ e.g., 2022-10-27T16:27:43.738+02:00.
64
+ kwargs
65
+ Key-value to persist in all log messages
66
+ """
21
67
super ().__init__ (
22
68
json_serializer ,
23
69
json_deserializer ,
0 commit comments