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 incorrect microsecond extraction in logging timestamps #844

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yaqian256
Copy link

@yaqian256 yaqian256 commented Feb 6, 2025

This PR fixes an issue in the logging module where the microsecond part of the timestamp was calculated incorrectly. Previously, the code used:

auto its_ms = (when_.time_since_epoch().count() / 100) % 1000000;

However, this approach incorrectly scaled the raw duration count. The correct division factor should have been 1000 (not 100), or better yet, the calculation can be performed in a type-safe manner using std::chrono::duration_cast.

The updated code now correctly extracts the microsecond portion by converting the duration to microseconds.

You can see the difference of the two approaches here!

Also updated .gitignore to ignore the .vs folder for Visual Studio.

@yaqian256
Copy link
Author

@GenivivSOMEIPmaintainer : Could you please review and consider this for master branch if it looks good to you?

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.

1 participant