analyze: add color highlighting when printing calendar elapses
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 22 Feb 2019 08:29:23 +0000 (09:29 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 22 Feb 2019 08:32:17 +0000 (09:32 +0100)
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.

src/analyze/analyze.c

index 337089a..77adbed 100644 (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())