Closed andrewkcorcoran closed 3 years ago
Do you mean something like this:
BINLOG_INFO("{} {} {}", std::chrono::minutes{1}, std::chrono::seconds{2}, std::chrono::milliseconds{3});
// Outputs: 1m 2s 3ms
For hours, minutes, seconds, milliseconds, microseconds, nanoseconds.
It could reuse the time portion of the datetime format string for logging purposes by default and possibly add an additional override just for times/durations.
I do not get this part: how would the timestamp format affect the formatting of individual duration objects?
Yea pretty much. I had thought the outputs could be 00:01:00 00:00:02 00:00:00.003 (hence the talk about formatting strings) but perhaps that's overcomplicating things?
On Fri, 16 Jul 2021, 11:17 am Thaler Benedek, @.***> wrote:
Do you mean something like this:
BINLOG_INFO("{} {} {}", std::chrono::minutes{1}, std::chrono::seconds{2}, std::chrono::milliseconds{3}); // Outputs: 1m 2s 3ms
For hours, minutes, seconds, milliseconds, microseconds, nanoseconds.
It could reuse the time portion of the datetime format string for logging purposes by default and possibly add an additional override just for times/durations.
I do not get this part: how would the timestamp format affect the formatting of individual duration objects?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/morganstanley/binlog/issues/129#issuecomment-881232608, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL5LS3AHESFOKTWLMH735WLTX7MJBANCNFSM5AM3OBKA .
Well, if the format string is "%H:%M:%S", representing milliseconds in a useful way would be challenging. Let's aim for a suffix notation for now. (e.g: 123ms)
To be generic and forward looking (e.g. for std::chrono::years
etc. maybe
we should look at serializing std::chrono::duration<Rep, Period>
instead
of individual serializers forstd::chrono::seconds/milliseconds
etc. We
could add overloads in the pretty printer to handle known std::ratios to
print a suffix such as s/ms/ns etc. and have a catch all which simply
prints the std::ratio
values for unspecified overloads (perhaps using the
names already defined in https://en.cppreference.com/w/cpp/header/ratio
e.g. picoseconds, gigaseconds etc.)
On Fri, 16 Jul 2021, 4:56 pm Thaler Benedek, @.***> wrote:
Well, if the format string is "%H:%M:%S", representing milliseconds in a useful way would be challenging. Let's aim for a suffix notation for now. (e.g: 123ms)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/morganstanley/binlog/issues/129#issuecomment-881426711, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL5LS3BPISIABLRWSYYKQELTYAT6BANCNFSM5AM3OBKA .
@andrewkcorcoran see https://github.com/morganstanley/binlog/pull/135
Currently it seems like the easiest way for users to output a
std::chrono::duration
object is to call::count()
on it (and remember tostd::chrono::duration_cast
it to a consistent ratio). It would be great if binlog had native support for durations in a similar fashion to the support added for std::chrono::time_point. It could reuse the time portion of the datetime format string for logging purposes by default and possibly add an additional override just for times/durations.