]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Implement silent logging level to minimize noise in logs
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 3 Apr 2018 17:04:27 +0000 (18:04 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 3 Apr 2018 17:04:27 +0000 (18:04 +0100)
src/libserver/cfg_file.h
src/libserver/cfg_rcl.c
src/libserver/worker_util.c

index ede88d9d761fb1cda4d5f9a46cdbd5a8d5b9cde7..da6ea56936eb622cb1e12543fcf1d57c4a9ec0a7 100644 (file)
@@ -325,6 +325,7 @@ struct rspamd_config {
        gint log_level;                                 /**< log level trigger                                                                  */
        gchar *log_file;                                /**< path to logfile in case of file logging                    */
        gboolean log_buffered;                          /**< whether logging is buffered                                                */
+       gboolean log_silent_workers;                    /**< silence info messages from workers                                 */
        guint32 log_buf_size;                           /**< length of log buffer                                                               */
        const ucl_object_t *debug_ip_map;               /**< turn on debugging for specified ip addresses       */
        gboolean log_urls;                              /**< whether we should log URLs                         */
index 08c7c7868cee217712c7ee7cf11c38f9b431c538..6019d7c7dd5ead18c31692508e9c1a9fbb7786df 100644 (file)
@@ -217,6 +217,13 @@ rspamd_rcl_logging_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
                else if (g_ascii_strcasecmp (log_level, "info") == 0) {
                        cfg->log_level = G_LOG_LEVEL_INFO | G_LOG_LEVEL_MESSAGE;
                }
+               else if (g_ascii_strcasecmp (log_level, "message") == 0) {
+                       cfg->log_level =  G_LOG_LEVEL_MESSAGE;
+               }
+               else if (g_ascii_strcasecmp (log_level, "silent") == 0) {
+                       cfg->log_level =  G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO;
+                       cfg->log_silent_workers = TRUE;
+               }
                else if (g_ascii_strcasecmp (log_level, "debug") == 0) {
                        cfg->log_level = G_LOG_LEVEL_DEBUG;
                }
index d2cca5b68884e889af758126f14d2fe125d7860d..c041561f890b43e53966d6b49db1d6c1d4ee7695 100644 (file)
@@ -636,6 +636,14 @@ rspamd_fork_worker (struct rspamd_main *rspamd_main,
 
                /* Do silent log reopen to avoid collisions */
                rspamd_log_close (rspamd_main->logger);
+
+
+               if (rspamd_main->cfg->log_silent_workers) {
+                       rspamd_main->cfg->log_level = G_LOG_LEVEL_MESSAGE;
+                       rspamd_set_logger (rspamd_main->cfg, cf->type,
+                                       &rspamd_main->logger, rspamd_main->server_pool);
+               }
+
                rspamd_log_open (rspamd_main->logger);
                wrk->start_time = rspamd_get_calendar_ticks ();