Skip to content

Commit ba76573

Browse files
Small changes
1 parent a4f82ec commit ba76573

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

docs/core/logger.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,11 @@ You can change the order of [standard Logger keys](#standard-structured-keys) or
570570

571571
#### Setting timestamp to custom Timezone
572572

573-
By default, this Logger and the standard logging library emit records with the default AWS Lambda timestamp in UTC.
573+
By default, this Logger and the standard logging library emit records with the default AWS Lambda timestamp in **UTC**.
574574

575-
However, if you want to use your preferred timezone to format your log instead, you can use the timezone environment variable `TZ`: Either set it as AWS Lambda environment variable, or setup this value directly in your Lambda function.
575+
<!-- markdownlint-disable MD013 -->
576+
If you prefer to log in a specific timezone, you can configure it by setting the `TZ` environment variable. You can do this either as an AWS Lambda environment variable or directly within your Lambda function settings. [Click here](https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime){target="_blank"} for a comprehensive list of available Lambda environment variables.
577+
<!-- markdownlint-enable MD013 -->
576578

577579
???+ tip
578580
`TZ` environment variable will be ignored if `utc` is set to `True`

tests/functional/test_logger_powertools_formatter.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,17 @@ def test_log_in_utc(service_name):
291291
logger = Logger(service=service_name, utc=True)
292292

293293
# THEN logging formatter time converter should use gmtime fn
294-
assert logger._logger.handlers[0].formatter.converter == time.gmtime
294+
assert logger.handlers[0].formatter.converter == time.gmtime
295295

296296

297-
def test_log_wo_utc(service_name):
297+
def test_log_with_localtime(service_name):
298298
# GIVEN a logger where UTC is false
299-
logger = Logger(service=service_name, utc=False)
299+
logger = Logger(service=service_name, utc=True)
300+
301+
print(logger.handlers[0].formatter.converter)
300302

301303
# THEN logging formatter time converter should use localtime fn
302-
assert logger._logger.handlers[0].formatter.converter == time.localtime
304+
assert logger.handlers[0].formatter.converter == time.localtime
303305

304306

305307
@pytest.mark.parametrize("message", ["hello", 1.10, {}, [], True, object()])

0 commit comments

Comments
 (0)