diff options
-rw-r--r-- | events/src/eventsapiconf.py.in | 4 | ||||
-rw-r--r-- | events/src/eventsconfig.json | 5 | ||||
-rw-r--r-- | events/src/utils.py | 15 |
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: |