util: make time formatting a bit smarter
Instead of outputting "5h 55s 50ms 3us" we'll now output "5h 55.050003s". Also, while outputting the accuracy is configurable. Basically we now try use "dot notation" for all time values > 1min. For >= 1s we use 's' as unit, otherwise for >= 1ms we use 'ms' as unit, and finally 'us'. This should give reasonably values in most cases.
This commit is contained in:
+2
-2
@@ -177,7 +177,7 @@ static void timer_dump(Unit *u, FILE *f, const char *prefix) {
|
||||
"%s%s: %s\n",
|
||||
prefix,
|
||||
timer_base_to_string(v->base),
|
||||
strna(format_timespan(timespan1, sizeof(timespan1), v->value)));
|
||||
strna(format_timespan(timespan1, sizeof(timespan1), v->value, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -330,7 +330,7 @@ static void timer_enter_waiting(Timer *t, bool initial) {
|
||||
log_debug_unit(UNIT(t)->id,
|
||||
"%s: Monotonic timer elapses in %s.",
|
||||
UNIT(t)->id,
|
||||
format_timespan(buf, sizeof(buf), t->next_elapse_monotonic > ts.monotonic ? t->next_elapse_monotonic - ts.monotonic : 0));
|
||||
format_timespan(buf, sizeof(buf), t->next_elapse_monotonic > ts.monotonic ? t->next_elapse_monotonic - ts.monotonic : 0, 0));
|
||||
|
||||
r = unit_watch_timer(UNIT(t), CLOCK_MONOTONIC, false, t->next_elapse_monotonic, &t->monotonic_watch);
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user