From ea251ef474e960f26e038aa1a51ae35e0c5f658e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Thu, 31 May 2018 14:03:11 +0200 Subject: [PATCH] Document LogMonitoringEventHandler --- .../log_monitoring_event_handler.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/tfw/components/log_monitoring_event_handler.py b/lib/tfw/components/log_monitoring_event_handler.py index e5687d0..078e2e8 100644 --- a/lib/tfw/components/log_monitoring_event_handler.py +++ b/lib/tfw/components/log_monitoring_event_handler.py @@ -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'])