From 4e647570f9469d33f5df8838e921fd8af796629e Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Fri, 9 Aug 2019 14:35:01 -0400 Subject: [PATCH] check for TTY and debug level early so that we don't erroneously add log prefixes, and then later stop using them. It's more important that debug output look OK, than the much rarer case of non-debug output sometimes looking off --- src/lib/server/main_config.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/lib/server/main_config.c b/src/lib/server/main_config.c index 4bbb765b200f..f1a1f6afc0ef 100644 --- a/src/lib/server/main_config.c +++ b/src/lib/server/main_config.c @@ -960,6 +960,19 @@ do {\ cs = cf_section_alloc(NULL, NULL, "main", NULL); if (!cs) return -1; + /* + * Special-case things. If the output is a TTY, AND + * we're debugging, colourise things. This flag also + * removes the "Debug : " prefix from the log messages. + */ + p = getenv("TERM"); + if (p && isatty(default_log.fd) && strstr(p, "xterm") && rad_debug_lvl) { + default_log.colourise = true; + } else { + default_log.colourise = false; + } + default_log.line_number = config->log_line_number; + /* * Add a 'feature' subsection off the main config * We check if it's defined first, as the user may @@ -1178,16 +1191,9 @@ do {\ if (cf_section_parse(config, config, cs) < 0) goto failure; /* - * We ignore colourization of output until after the - * configuration files have been parsed. + * Reset the colourisation state. */ - p = getenv("TERM"); - if (config->do_colourise && p && isatty(default_log.fd) && strstr(p, "xterm")) { - default_log.colourise = true; - } else { - default_log.colourise = false; - } - default_log.line_number = config->log_line_number; + default_log.colourise = config->do_colourise; /* * Starting the server, WITHOUT "-x" on the