1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-25 06:03:40 +03:00

analyze: add color highlighting when printing calendar elapses

With multiple iterations, I found it hard to pick out the interesting bits in
the column of text. I tried plain highlighting first, but it doesn't seem
enough. But blue/yellow makes it easy to jump to the right iteration.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-02-22 09:29:23 +01:00
parent 84653d99fa
commit deed4d50a2

View File

@ -1700,14 +1700,16 @@ static int test_calendar_one(usec_t n, const char *p) {
r = calendar_spec_next_usec(spec, n, &next);
if (r == -ENOENT) {
if (i == 0)
printf(" Next elapse: never\n");
printf(" Next elapse: %snever%s\n",
ansi_highlight_yellow(), ansi_normal());
return 0;
}
if (r < 0)
return log_error_errno(r, "Failed to determine next elapse for '%s': %m", p);
if (i == 0)
printf(" Next elapse: %s\n", format_timestamp(buffer, sizeof(buffer), next));
printf(" Next elapse: %s%s%s\n",
ansi_highlight_blue(), format_timestamp(buffer, sizeof(buffer), next), ansi_normal());
else {
int k = DECIMAL_STR_WIDTH(i+1);
@ -1716,7 +1718,9 @@ static int test_calendar_one(usec_t n, const char *p) {
else
k = 0;
printf("%*sIter. #%u: %s\n", k, "", i+1, format_timestamp(buffer, sizeof(buffer), next));
printf("%*sIter. #%u: %s%s%s\n",
k, "", i+1,
ansi_highlight_blue(), format_timestamp(buffer, sizeof(buffer), next), ansi_normal());
}
if (!in_utc_timezone())