-
Notifications
You must be signed in to change notification settings - Fork 421
fix(logger): force Logger to use local timezone when UTC flag is not set #3168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAll modified lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## develop #3168 +/- ##
========================================
Coverage 95.96% 95.96%
========================================
Files 195 195
Lines 8381 8382 +1
Branches 1562 1562
========================================
+ Hits 8043 8044 +1
Misses 276 276
Partials 62 62
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @roger-zhangg! Another PR with simple and extremely high-quality solutions. You're smashing it, man.
I left some comments we need to address before merging this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heitorlessa or @rubenfonseca, can you make a last review of this PR, please?
LGTM! Approving!
e2e test output poetry run pytest tests/e2e/logger/test_logger.py
/local/home/ruojiazh/projects/aws-lambda-powertools-python/.venv/lib/python3.10/site-packages/pytest_benchmark/logger.py:46: PytestBenchmarkWarning: Benchmarks are automatically disabled because xdist plugin is active.Benchmarks cannot be performed reliably in a parallelized environment.
warner(PytestBenchmarkWarning(text))
================================================================== test session starts ==================================================================
platform linux -- Python 3.10.2, pytest-7.4.2, pluggy-1.2.0 -- /local/home/ruojiazh/projects/aws-lambda-powertools-python/.venv/bin/python
cachedir: .pytest_cache
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /local/home/ruojiazh/projects/aws-lambda-powertools-python/tests/e2e
configfile: pytest.ini
plugins: typeguard-2.13.3, ddtrace-1.15.2, anyio-3.7.1, cov-4.1.0, xdist-3.3.1, mock-3.11.1, benchmark-4.0.0, socket-0.6.0, asyncio-0.21.1
asyncio: mode=strict
collected 13 items
tests/e2e/logger/test_logger.py::test_basic_lambda_logs_visible PASSED [ 7%]
tests/e2e/logger/test_logger.py::test_lambda_tz[%z-US/Eastern-False] PASSED [ 15%]
tests/e2e/logger/test_logger.py::test_lambda_tz[%z-US/Eastern-True] PASSED [ 23%]
tests/e2e/logger/test_logger.py::test_lambda_tz[%z-UTC-False] PASSED [ 30%]
tests/e2e/logger/test_logger.py::test_lambda_tz[%z-UTC-True] PASSED [ 38%]
tests/e2e/logger/test_logger.py::test_lambda_tz[%z-Asia/Shanghai-False] PASSED [ 46%]
tests/e2e/logger/test_logger.py::test_lambda_tz[%z-Asia/Shanghai-True] PASSED [ 53%]
tests/e2e/logger/test_logger.py::test_lambda_tz[None-US/Eastern-False] PASSED [ 61%]
tests/e2e/logger/test_logger.py::test_lambda_tz[None-US/Eastern-True] PASSED [ 69%]
tests/e2e/logger/test_logger.py::test_lambda_tz[None-UTC-False] PASSED [ 76%]
tests/e2e/logger/test_logger.py::test_lambda_tz[None-UTC-True] PASSED [ 84%]
tests/e2e/logger/test_logger.py::test_lambda_tz[None-Asia/Shanghai-False] PASSED [ 92%]
tests/e2e/logger/test_logger.py::test_lambda_tz[None-Asia/Shanghai-True] PASSED [100%]
=================================================================== warnings summary ====================================================================
.venv/lib/python3.10/site-packages/ddtrace/internal/module.py:220
/local/home/ruojiazh/projects/aws-lambda-powertools-python/.venv/lib/python3.10/site-packages/ddtrace/internal/module.py:220: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
self.loader.exec_module(module)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================= 13 passed, 1 warning in 215.94s (0:03:35) =======================================================
(23-10-10 15:59:23) <0> [~/projects/aws-lambda-powertools-python] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks mostly good - E2E test should be split, and Lambda Handler needs comments.
A rule of thumb is that the minute you need If/Else, For/While Loops in a test, you need to break them.
We run tests in parallel so there isn't a penalty for adding more granular E2E tests in this case.
…s-python into tz_fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Kudos, SonarCloud Quality Gate passed!
|
Issue number: #3154
Summary
Changes
Previously logging ignores TZ env value, this fix make logging follows local TZ value when UTC flag is not set
User experience
UX not affected
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.