From 01e27f52fa7dfcf6b47dda784e01c379fd61906c Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 14 Nov 2016 13:19:28 +0000 Subject: [PATCH] [Feature] Add configuration knobs for the errors circular buffer --- src/libserver/cfg_file.h | 2 ++ src/libserver/cfg_rcl.c | 14 +++++++++++++- src/libserver/cfg_utils.c | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index 1980c1455..1f31d372e 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -326,6 +326,8 @@ struct rspamd_config { gboolean log_extended; /**< log extended information */ gboolean log_systemd; /**< special case for systemd logger */ gboolean log_re_cache; /**< show statistics about regexps */ + guint log_error_elts; /**< number of elements in error logbuf */ + guint log_error_elt_maxlen; /**< maximum size of error log element */ gboolean mlock_statfile_pool; /**< use mlock (2) for locking statfiles */ diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index a260ca99a..8b6d6bfd4 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -1628,7 +1628,7 @@ rspamd_rcl_config_init (struct rspamd_config *cfg) "log_buffer", rspamd_rcl_parse_struct_integer, G_STRUCT_OFFSET (struct rspamd_config, log_buf_size), - 0, + RSPAMD_CL_FLAG_INT_32, "Size of log buffer in bytes (for file logging)"); rspamd_rcl_add_default_handler (sub, "log_urls", @@ -1698,6 +1698,18 @@ rspamd_rcl_config_init (struct rspamd_config *cfg) G_STRUCT_OFFSET (struct rspamd_config, log_encryption_key), 0, "Encrypt sensitive information in logs using this pubkey"); + rspamd_rcl_add_default_handler (sub, + "error_elts", + rspamd_rcl_parse_struct_integer, + G_STRUCT_OFFSET (struct rspamd_config, log_error_elts), + RSPAMD_CL_FLAG_UINT, + "Size of circular buffer for last errors (10 by default)"); + rspamd_rcl_add_default_handler (sub, + "error_maxlen", + rspamd_rcl_parse_struct_integer, + G_STRUCT_OFFSET (struct rspamd_config, log_error_elt_maxlen), + RSPAMD_CL_FLAG_UINT, + "Size of each element in error log buffer (1000 by default)"); /** * Options section */ diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 9daa90af8..38aad8d6c 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -141,6 +141,8 @@ rspamd_config_new (void) cfg->dns_max_requests = 64; cfg->history_rows = 200; + cfg->log_error_elts = 10; + cfg->log_error_elt_maxlen = 1000; /* Default log line */ cfg->log_format_str = "id: <$mid>,$if_qid{ qid: <$>,}$if_ip{ ip: $,}" -- 2.39.5