diff options
author | Aravinda VK <avishwan@redhat.com> | 2016-10-18 16:58:36 +0530 |
---|---|---|
committer | Aravinda VK <avishwan@redhat.com> | 2016-12-08 01:22:35 -0800 |
commit | ff2314995b117b33d81beb6de7b043979c676aeb (patch) | |
tree | 6828269d27a9f79f81f6d326cd304b1bae26cbb2 /events/src/utils.py | |
parent | 41a71b47f75a52f50ad2754cce679407ebade767 (diff) |
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 <avishwan@redhat.com>
Reviewed-on: http://review.gluster.org/15674
Reviewed-by: Prashanth Pai <ppai@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'events/src/utils.py')
-rw-r--r-- | events/src/utils.py | 15 |
1 files changed, 12 insertions, 3 deletions
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: |