From 8b46691877e0b1158b908f2cdc0b46c419382762 Mon Sep 17 00:00:00 2001 From: Romain THERRAT Date: Thu, 9 Apr 2015 12:02:05 +0200 Subject: [PATCH] Add log_invalid_line option (Fix #5) --- etc/modules/logstore_mongodb.cfg | 3 +++ module/module.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/etc/modules/logstore_mongodb.cfg b/etc/modules/logstore_mongodb.cfg index bc3d5e9..976eb5e 100644 --- a/etc/modules/logstore_mongodb.cfg +++ b/etc/modules/logstore_mongodb.cfg @@ -13,4 +13,7 @@ define module { #database #collection #max_logs_age + + # Uncoment next line in order to display "This line is invalid" log line. + #log_invalid_line 1 } diff --git a/module/module.py b/module/module.py index c6a9d0d..183823c 100644 --- a/module/module.py +++ b/module/module.py @@ -126,6 +126,7 @@ def __init__(self, modconf): elif maxmatch.group(2) == 'y': self.max_logs_age = int(maxmatch.group(1)) * 365 self.use_aggressive_sql = (getattr(modconf, 'use_aggressive_sql', '1') == '1') + self.log_invalid_line = to_bool(getattr(modconf, 'log_invalid_line', 'False')) # This stack is used to create a full-blown select-statement self.mongo_filter_stack = LiveStatusMongoStack() # This stack is used to create a minimal select-statement which @@ -243,7 +244,8 @@ def manage_log_brok(self, b): logger.error("[LogStoreMongoDB] Databased error occurred: %s" % exp) # FIXME need access to this #self.livestatus.count_event('log_message') else: - logger.info("[LogStoreMongoDB] This line is invalid: %s" % line) + if self.log_invalid_line: + logger.info("[LogStoreMongoDB] This line is invalid: %s" % line) def add_filter(self, operator, attribute, reference):