]> source.dussan.org Git - rspamd.git/commitdiff
Fix colored logging.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 6 May 2015 12:46:29 +0000 (13:46 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 6 May 2015 12:46:29 +0000 (13:46 +0100)
src/libserver/cfg_rcl.c
src/libutil/logger.c

index ab3d2170266bf6dfb2f366766321b46563e12497..5869bd6fb04931b4969bb8309e7eff3912c61f71 100644 (file)
@@ -1221,6 +1221,11 @@ rspamd_rcl_config_init (void)
                rspamd_rcl_parse_struct_boolean,
                G_STRUCT_OFFSET (struct rspamd_config, log_color),
                0);
+       rspamd_rcl_add_default_handler (sub,
+               "color",
+               rspamd_rcl_parse_struct_boolean,
+               G_STRUCT_OFFSET (struct rspamd_config, log_color),
+               0);
        /**
         * Options section
         */
index b948deaf171dfb2f2f078fdbc7e34829bdfbce05..3728b2fb4d340c7cee5bf84b0a687cd575e982bb 100644 (file)
@@ -697,15 +697,15 @@ file_log_function (const gchar * log_domain,
                        cptype = g_quark_to_string (rspamd_log->process_type);
 
                        if (rspamd_log->cfg->log_color) {
-                               if (log_level >= G_LOG_LEVEL_INFO) {
+                               if (log_level == G_LOG_LEVEL_INFO) {
                                        /* White */
-                                       r = rspamd_snprintf (tmpbuf, sizeof (tmpbuf), "\033[1;37m");
+                                       r = rspamd_snprintf (tmpbuf, sizeof (tmpbuf), "\033[0;37m");
                                }
-                               else if (log_level >= G_LOG_LEVEL_WARNING) {
+                               else if (log_level == G_LOG_LEVEL_WARNING) {
                                        /* Magenta */
-                                       r = rspamd_snprintf (tmpbuf, sizeof (tmpbuf), "\033[2;32m");
+                                       r = rspamd_snprintf (tmpbuf, sizeof (tmpbuf), "\033[0;32m");
                                }
-                               else if (log_level >= G_LOG_LEVEL_CRITICAL) {
+                               else if (log_level == G_LOG_LEVEL_CRITICAL) {
                                        /* Red */
                                        r = rspamd_snprintf (tmpbuf, sizeof (tmpbuf), "\033[1;31m");
                                }