From ff2314995b117b33d81beb6de7b043979c676aeb Mon Sep 17 00:00:00 2001 From: Aravinda VK Date: Tue, 18 Oct 2016 16:58:36 +0530 Subject: eventsapi: Log all published events and provide option to disable logging Log every published event in /var/log/glusterfs/events.log, Disable logging using, gluster-eventsapi config-set disable-events-log true Also changed "log_level" config name to "log-level" Change-Id: Ib354be0c4ca999d1ccd01b810d6cd96ebc72bcd4 BUG: 1386200 Signed-off-by: Aravinda VK Reviewed-on: http://review.gluster.org/15674 Reviewed-by: Prashanth Pai Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- events/src/utils.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'events/src/utils.py') diff --git a/events/src/utils.py b/events/src/utils.py index 256cfca0fc2..2a77b13d502 100644 --- a/events/src/utils.py +++ b/events/src/utils.py @@ -48,6 +48,12 @@ def boolify(value): return False +def log_event(data): + # Log all published events unless it is disabled + if not _config.get("disable-events-log", False): + logger.info(repr(data)) + + def get_node_uuid(): val = None with open(UUID_FILE) as f: @@ -58,10 +64,10 @@ def get_node_uuid(): return val -def get_config(key): +def get_config(key, default_value=None): if not _config: load_config() - return _config.get(key, None) + return _config.get(key, default_value) def get_event_type_name(idx): @@ -111,7 +117,7 @@ def load_log_level(): be triggered during init and when SIGUSR2. """ global logger, _log_level - new_log_level = _config.get("log_level", "INFO") + new_log_level = _config.get("log-level", "INFO") if _log_level != new_log_level: logger.setLevel(getattr(logging, new_log_level.upper())) _log_level = new_log_level.upper() @@ -153,6 +159,9 @@ def publish(ts, event_key, data): "event": get_event_type_name(event_key), "message": data } + + log_event(message) + if _webhooks: plugin_webhook(message) else: -- cgit