Skip to content

Commit 311ff50

Browse files
committed
docs: mention new use_datetime_directive usage
1 parent 0ab103c commit 311ff50

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

aws_lambda_powertools/logging/logger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ class Logger(logging.Logger): # lgtm [py/missing-call-to-init]
7878
custom logging handler e.g. logging.FileHandler("file.log")
7979
8080
Parameters propagated to LambdaPowertoolsFormatter
81-
---------------------------------------------
81+
--------------------------------------------------
8282
datefmt: str, optional
8383
String directives (strftime) to format log timestamp using `time`, by default it uses RFC
8484
3339.
85-
use_datetime: str, optional
85+
use_datetime_directive: str, optional
8686
Interpret `datefmt` as a format string for `datetime.datetime.strftime`, rather than
8787
`time.strftime`.
8888

docs/core/logger.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ Parameter | Description | Default
656656
**`json_deserializer`** | function to deserialize `str`, `bytes`, `bytearray` containing a JSON document to a Python obj | `json.loads`
657657
**`json_default`** | function to coerce unserializable values, when no custom serializer/deserializer is set | `str`
658658
**`datefmt`** | string directives (strftime) to format log timestamp | `%Y-%m-%d %H:%M:%S,%F%z`, where `%F` is a custom ms directive
659-
**`use_datetime`** | format the `datefmt` timestamps using `datetime`, not `time` (also supports the custom `%F` directive for milliseconds) | `False`
659+
**`use_datetime_directive`** | format the `datefmt` timestamps using `datetime`, not `time` (also supports the custom `%F` directive for milliseconds) | `False`
660660
**`utc`** | set logging timestamp to UTC | `False`
661661
**`log_record_order`** | set order of log keys when logging | `["level", "location", "message", "timestamp"]`
662662
**`kwargs`** | key-value to be included in log messages | `None`
@@ -727,13 +727,17 @@ In this case, Logger will register a Logger named `payment`, and a Logger named
727727

728728
#### Overriding Log records
729729

730+
???+ tip
731+
Use `datefmt` for custom date formats - We honour standard [logging library string formats](https://docs.python.org/3/howto/logging.html#displaying-the-date-time-in-messages){target="_blank"}.
732+
733+
Prefer using [datetime string formats](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes){target="_blank"}? Set `use_datetime_directive` at Logger constructor or at [Lambda Powertools Formatter](#lambdapowertoolsformatter).
734+
730735
You might want to continue to use the same date formatting style, or override `location` to display the `package.function_name:line_number` as you previously had.
731736

732737
Logger allows you to either change the format or suppress the following keys altogether at the initialization: `location`, `timestamp`, `level`, `xray_trace_id`.
733738

734-
=== "lambda_handler.py"
735-
> We honour standard [logging library string formats](https://docs.python.org/3/howto/logging.html#displaying-the-date-time-in-messages){target="_blank"}.
736739

740+
=== "lambda_handler.py"
737741
```python hl_lines="7 10"
738742
from aws_lambda_powertools import Logger
739743

0 commit comments

Comments
 (0)