-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Do not truncate Logger timestamps #5871
Conversation
end | ||
|
||
@doc """ | ||
Formats time as chardata. | ||
""" | ||
def format_time({hh, mi, ss, ms}) do | ||
[pad2(hh), ?:, pad2(mi), ?:, pad2(ss), ?., pad3(ms)] |
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.
In order to not change the output currently logged, let's make this be:
[pad2(hh), ?:, pad2(mi), ?:, pad2(ss), ?., ms |> div(1000) |> pad3()]
If you want to log with higher precision, then you can always call your own format_time
function.
This way you get higher precision in the backend but remove the precision only when formatting, as you mentioned.
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.
Sure, makes sense. I'll update.
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.
Ok, all set.
This would be a breaking change, so would have to be opt-in. I would rather we support an option to use a date time struct. |
@fishcakez you are right. We are changing the meaning of the tuple element. I think having an option for using time structs is likely the way to go here. |
Sure, do you mind explaining why this is breaking? And does this mean Elixir is locked in at millisecond precision for logging, by default? |
We support custom formatting functions, and these receive the timestamp tuple, which is currently milliseconds. See
Yes |
Thanks. I'll update this to take an option. |
Hi @binarylogic! I am closing this PR as, per the discussion above, it is backwards incompatible. Instead, we should probably move to a NaiveDateTime struct, configured via an option. Thank you! |
Is there any reason why the precision on
Logger
timestamps is being truncated? If so, can this be commented / documented somewhere?A few reasons we should not do this:
Thanks for taking a look!