[PATCH] config: Support setting a default suppress() globally.

Gergely Nagy algernon at balabit.hu
Fri Mar 4 10:56:55 CET 2011


While setting suppress() on a per-destination basis is flexible, when
one wants to have the same setting for all destinations by default,
it's more convenient to do that globally in the options block.

That is implemented herein: one can set a global suppress(), and it
will be the default for all destinations that support it, yet, can
still be overridden on a per-destination basis.

Signed-off-by: Gergely Nagy <algernon at balabit.hu>
---
 lib/cfg-grammar.y |    1 +
 lib/cfg.h         |    1 +
 lib/logwriter.c   |    4 +++-
 3 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lib/cfg-grammar.y b/lib/cfg-grammar.y
index 8d45af3..0a78b68 100644
--- a/lib/cfg-grammar.y
+++ b/lib/cfg-grammar.y
@@ -600,6 +600,7 @@ options_item
 	| KW_TIME_REOPEN '(' LL_NUMBER ')'		{ configuration->time_reopen = $3; }
 	| KW_TIME_REAP '(' LL_NUMBER ')'		{ configuration->time_reap = $3; }
 	| KW_TIME_SLEEP '(' LL_NUMBER ')'	{}
+	| KW_SUPPRESS '(' LL_NUMBER ')'		{ configuration->suppress = $3; }
 	| KW_THREADED '(' yesno ')'		{ configuration->threaded = $3; }
 	| KW_LOG_FIFO_SIZE '(' LL_NUMBER ')'	{ configuration->log_fifo_size = $3; }
 	| KW_LOG_IW_SIZE '(' LL_NUMBER ')'	{ msg_error("Using a global log-iw-size() option was removed, please use a per-source log-iw-size()", NULL); }
diff --git a/lib/cfg.h b/lib/cfg.h
index 455b36d..82a30c5 100644
--- a/lib/cfg.h
+++ b/lib/cfg.h
@@ -76,6 +76,7 @@ struct _GlobalConfig
   gchar *dns_cache_hosts;
   gint time_reopen;
   gint time_reap;
+  gint suppress;
 
   gint log_fifo_size;
   gint log_msg_size;
diff --git a/lib/logwriter.c b/lib/logwriter.c
index 0a21876..5586230 100644
--- a/lib/logwriter.c
+++ b/lib/logwriter.c
@@ -1079,7 +1079,7 @@ log_writer_options_defaults(LogWriterOptions *options)
   options->flush_timeout = -1;
   log_template_options_defaults(&options->template_options);
   options->time_reopen = -1;
-  options->suppress = 0;
+  options->suppress = -1;
 }
 
 void 
@@ -1155,6 +1155,8 @@ log_writer_options_init(LogWriterOptions *options, GlobalConfig *cfg, guint32 op
     options->flush_lines = cfg->flush_lines;
   if (options->flush_timeout == -1)
     options->flush_timeout = cfg->flush_timeout;
+  if (options->suppress == -1)
+    options->suppress = cfg->suppress;
     
   if (options->mem_fifo_size < options->flush_lines)
     {
-- 
1.7.0.4

--8<---------------cut here---------------end--------------->8---


More information about the syslog-ng mailing list