Document LogMonitoringEventHandler

This commit is contained in:
Kristóf Tóth 2018-05-31 14:03:11 +02:00
parent b68ceeb394
commit ea251ef474

View File

@ -10,6 +10,12 @@ LOG = logging.getLogger(__name__)
class LogMonitoringEventHandler(EventHandlerBase, MonitorManagerMixin):
"""
Monitors the output of a supervisor process (stdout, stderr) and
sends the results to the frontend.
Exposes API to change monitoring parameters.
"""
def __init__(self, key, process_name, log_tail=0):
super().__init__(key)
self.process_name = process_name
@ -30,7 +36,21 @@ class LogMonitoringEventHandler(EventHandlerBase, MonitorManagerMixin):
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
def handle_process_name(self, data):
"""
Changes the monitored process.
:param data: TFW message data containing keys:
|-value: name of the process to monitor
"""
self.set_monitor_args(data['value'], self.log_tail)
def handle_log_tail(self, data):
"""
Sets tail length of the log the monitor will send
to the frontend (the monitor will send back the last
'value' characters of the log).
:param data: TFW message data containing keys:
|-value: new tail length
"""
self.set_monitor_args(self.process_name, data['value'])