]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Start variable log format support.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 5 Nov 2015 12:54:48 +0000 (15:54 +0300)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 5 Nov 2015 12:54:48 +0000 (15:54 +0300)
src/libserver/cfg_file.h
src/libserver/cfg_rcl.c
src/libserver/cfg_utils.c

index 5f1abe1b0aa81061bea986aa62cab520a04d9126..416053aba4afbabd4b0d4242afe36cc555e987ee 100644 (file)
@@ -165,6 +165,38 @@ struct rspamd_worker_conf {
        ucl_object_t *options;                  /**< other worker's options                                                             */
 };
 
+enum rspamd_log_format_type {
+       RSPAMD_LOG_STRING = 0,
+       RSPAMD_LOG_MID,
+       RSPAMD_LOG_QID,
+       RSPAMD_LOG_USER,
+       RSPAMD_LOG_ISSPAM,
+       RSPAMD_LOG_ACTION,
+       RSPAMD_LOG_SCORES,
+       RSPAMD_LOG_SYMBOLS,
+       RSPAMD_LOG_IP,
+       RSPAMD_LOG_DNS_REQ,
+       RSPAMD_LOG_SMTP_FROM,
+       RSPAMD_LOG_MIME_FROM,
+       RSPAMD_LOG_TIME_REAL,
+       RSPAMD_LOG_TIME_VIRTUAL,
+       RSPAMD_LOG_LUA
+};
+
+enum rspamd_log_format_flags {
+       RSPAMD_LOG_FLAG_DEFAULT = 0,
+       RSPAMD_LOG_FLAG_OPTIONAL = (1 << 0),
+       RSPAMD_LOG_FLAG_MIME_ALTERNATIVE = (1 << 1),
+       RSPAMD_LOG_FLAG_CONDITION = (1 << 2)
+};
+
+struct rspamd_log_format {
+       enum rspamd_log_format_type type;
+       guint flags;
+       gpointer data;
+       struct rspamd_log_format *prev, *next;
+};
+
 /**
  * Structure that stores all config data
  */
@@ -277,6 +309,8 @@ struct rspamd_config {
        GList *classify_headers;                                                /**< list of headers using for statistics                               */
        struct module_s **compiled_modules;                             /**< list of compiled C modules                                                 */
        struct worker_s **compiled_workers;                             /**< list of compiled C modules                                                 */
+       struct rspamd_log_format *log_format;                   /**< parsed log format                                                                  */
+       gchar *log_format_str;                                                  /**< raw log format string                                                              */
 };
 
 
index b572fd59c0e866735962a5a2ee3c3f06e9736e55..b42f2241c214fe8c752f4a17c05964f8fae5ddb5 100644 (file)
@@ -1254,6 +1254,11 @@ rspamd_rcl_config_init (void)
                        rspamd_rcl_parse_struct_string_list,
                        G_STRUCT_OFFSET (struct rspamd_config, debug_modules),
                        RSPAMD_CL_FLAG_STRING_LIST_HASH);
+       rspamd_rcl_add_default_handler (sub,
+                       "log_format",
+                       rspamd_rcl_parse_struct_string,
+                       G_STRUCT_OFFSET (struct rspamd_config, log_format_str),
+                       0);
        /**
         * Options section
         */
index 1aae2c12d429658898cf03100cb500a7a63f6b5d..bad00db8a91e349959e54c709d9be9ec22210690 100644 (file)
@@ -177,6 +177,12 @@ rspamd_config_defaults (struct rspamd_config *cfg)
        cfg->min_word_len = DEFAULT_MIN_WORD;
        cfg->dns_max_requests = 64;
        cfg->history_rows = 200;
+
+       /* Default log line */
+       cfg->log_format_str = "id: <$mid>, $if_qid{qid: <$>,} $if_ip{ip: $,}"
+                       "$if_ip{ip: $,} $if_from{from: <$>,} (default: $is_spam "
+                       "($action): [$scores] [$symbols]), len: $len, time: $time_real real,"
+                       " $time_virtual virtual, dns req: $dns_req";
 }
 
 void