Skip to content
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

Fix(common): format logs in correct local timezone #1032

Merged
merged 4 commits into from
Jun 23, 2023

Conversation

timonv
Copy link
Contributor

@timonv timonv commented Jun 21, 2023

Description of change

Logs were formatted in UTC regardless of local timezone, resulting in incorrect times. We now format the datetime with rfc3339 which includes the correct timezone.

Testing is a bit hacky with the mutex, as per the comment, Time uses libc to get the timezone. By forcing the env var to the expected timezone we get the result we want. Originally had more than one test, hence the mutex. Decided to leave it in, as any additional test using timezones would yield crazy racing errors. Happy to remove it if needed.

Closes #834

How has this been tested? (if applicable)

Added unit tests.
Having some issues running the full test suite / local env. Should be alright but timezones.

Logs were formatted in UTC regardless of local timezone, resulting in
incorrect times. We now format the datetime with rfc3339 which includes
the correct timezone.
@timonv timonv changed the title Fix(common): logs formatted in wrong timezone Fix(common): format logs in correct local timezone Jun 21, 2023
Copy link
Contributor

@chesedo chesedo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks @timonv! 🥳

I left some cleanup related comments

common/src/lib.rs Outdated Show resolved Hide resolved
common/src/log.rs Outdated Show resolved Hide resolved
@timonv timonv requested a review from chesedo June 21, 2023 13:54
@timonv
Copy link
Contributor Author

timonv commented Jun 21, 2023

Thanks for the feedback, added a clarifying comment, cleaned up and readded dim()

@timonv
Copy link
Contributor Author

timonv commented Jun 22, 2023

Having some issues running the full test suite / local env. Should be alright but timezones.

image

Correct time & timezone

Copy link
Contributor

@oddgrd oddgrd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks Timon! Thanks for the test, the screenshot and the thorough PR description as well 😍

@oddgrd oddgrd merged commit e770349 into shuttle-hq:main Jun 23, 2023
@timonv timonv deleted the localized-log-timestamps branch June 23, 2023 10:08
AlphaKeks pushed a commit to AlphaKeks/shuttle that referenced this pull request Jul 21, 2023
* Fix logs formatted in wrong timezone

Logs were formatted in UTC regardless of local timezone, resulting in
incorrect times. We now format the datetime with rfc3339 which includes
the correct timezone.

* Remove mutex

* Reset Cargo.toml to main

* Add back datetime dim() formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: shuttle deploy incorrectly reports times as "Zulu"
3 participants