]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Check whether it's appropriate to output colourised log messages
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 18 Feb 2013 15:42:09 +0000 (10:42 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 18 Feb 2013 15:42:09 +0000 (10:42 -0500)
raddb/radiusd.conf.in
src/main/mainconfig.c

index f2a3ef777230e56869098c972e44d860610c6bb9..fd2d6ea8631a922e640f09173ee1c4588789e90a 100644 (file)
@@ -213,6 +213,9 @@ log {
        #
        #  Highlight important messages sent to stderr and stdout.
        #
+       #  Option will be ignored (disabled) if output if TERM is not
+       #  an xterm or output is not to a TTY.
+       #
        colourise = yes
 
        #
index 1972afb9969c683edc586e7889c446c0236dcc12..4f4d5f052fdabea1f76b52d22672bfffb0e108cc 100644 (file)
@@ -883,6 +883,15 @@ int read_mainconfig(int reload)
                }
        }
 
+       /* Check whether it's appropriate to colourise log output */
+       p = getenv("TERM");
+       if (!(((mainconfig.radlog_dest == RADLOG_STDOUT) ||
+             (mainconfig.radlog_dest == RADLOG_STDERR)) &&
+             isatty(mainconfig.radlog_fd) && p && strstr(p, "xterm"))) {
+               mainconfig.colourise = FALSE;
+       }
+       p = NULL;
+       
        /* Initialize the dictionary */
        cp = cf_pair_find(cs, "dictionary");
        if (cp) p = cf_pair_value(cp);