Skip to content

Commit dd58bb5

Browse files
committed
chore: add docstring and note on field change
1 parent ad667d5 commit dd58bb5

File tree

1 file changed

+47
-1
lines changed
  • aws_lambda_powertools/logging/formatters

1 file changed

+47
-1
lines changed

aws_lambda_powertools/logging/formatters/datadog.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,55 @@ def __init__(
1515
use_datetime_directive: bool = False,
1616
log_record_order: list[str] | None = None,
1717
utc: bool = False,
18-
use_rfc3339: bool = True,
18+
use_rfc3339: bool = True, # NOTE: The only change from our base formatter
1919
**kwargs,
2020
):
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+
"""
2167
super().__init__(
2268
json_serializer,
2369
json_deserializer,

0 commit comments

Comments
 (0)