[systemd-devel] [PATCH 05/17] journalctl: no color for --reboot-- when not on tty
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Fri Jun 7 21:22:37 PDT 2013
---
src/journal/journalctl.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index a389543..d89684b 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1334,12 +1334,14 @@ int main(int argc, char *argv[]) {
if (!arg_merge) {
sd_id128_t boot_id;
+ const char *color_on = on_tty() ? ANSI_HIGHLIGHT_ON : "",
+ *color_off = on_tty() ? ANSI_HIGHLIGHT_OFF : "";
r = sd_journal_get_monotonic_usec(j, NULL, &boot_id);
if (r >= 0) {
if (previous_boot_id_valid &&
!sd_id128_equal(boot_id, previous_boot_id))
- printf(ANSI_HIGHLIGHT_ON "-- Reboot --" ANSI_HIGHLIGHT_OFF "\n");
+ printf("%s-- Reboot --%s\n", color_on, color_off);
previous_boot_id = boot_id;
previous_boot_id_valid = true;
--
1.8.2.562.g931e949
More information about the systemd-devel
mailing list