summaryrefslogtreecommitdiffstats
path: root/events/src
diff options
context:
space:
mode:
authorAravinda VK <avishwan@redhat.com>2016-10-18 16:58:36 +0530
committerAravinda VK <avishwan@redhat.com>2016-12-08 01:22:35 -0800
commitff2314995b117b33d81beb6de7b043979c676aeb (patch)
tree6828269d27a9f79f81f6d326cd304b1bae26cbb2 /events/src
parent41a71b47f75a52f50ad2754cce679407ebade767 (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')
-rw-r--r--events/src/eventsapiconf.py.in4
-rw-r--r--events/src/eventsconfig.json5
-rw-r--r--events/src/utils.py15
3 files changed, 17 insertions, 7 deletions
diff --git a/events/src/eventsapiconf.py.in b/events/src/eventsapiconf.py.in
index 85fefebbbbf..08a3602f567 100644
--- a/events/src/eventsapiconf.py.in
+++ b/events/src/eventsapiconf.py.in
@@ -17,8 +17,8 @@ WEBHOOKS_FILE_TO_SYNC = "/events/webhooks.json"
WEBHOOKS_FILE = "@GLUSTERD_WORKDIR@" + WEBHOOKS_FILE_TO_SYNC
LOG_FILE = "@localstatedir@/log/glusterfs/events.log"
EVENTSD = "glustereventsd"
-CONFIG_KEYS = ["log_level", "port"]
-BOOL_CONFIGS = []
+CONFIG_KEYS = ["log-level", "port", "disable-events-log"]
+BOOL_CONFIGS = ["disable-events-log"]
INT_CONFIGS = ["port"]
RESTART_CONFIGS = ["port"]
EVENTS_ENABLED = @EVENTS_ENABLED@
diff --git a/events/src/eventsconfig.json b/events/src/eventsconfig.json
index 45730f9bb83..89e5b9c1d68 100644
--- a/events/src/eventsconfig.json
+++ b/events/src/eventsconfig.json
@@ -1,4 +1,5 @@
{
- "log_level": "INFO",
- "port": 24009
+ "log-level": "INFO",
+ "port": 24009,
+ "disable-events-log": false
}
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: