mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-22 18:31:55 +00:00
Implement LogMonitorEH API
This commit is contained in:
parent
211ae1e2d9
commit
2e953ea098
@ -4,12 +4,34 @@
|
||||
|
||||
from tfw import EventHandlerBase
|
||||
from tfw.mixins import MonitorManagerMixin
|
||||
from tfw.config.logs import logging
|
||||
from .log_monitor import LogMonitor
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LogMonitoringEventHandler(EventHandlerBase, MonitorManagerMixin):
|
||||
def __init__(self, process_name, log_tail=0):
|
||||
MonitorManagerMixin.__init__(self, LogMonitor, process_name, log_tail)
|
||||
def __init__(self, key, process_name, log_tail=0):
|
||||
super().__init__(key)
|
||||
self.process_name = process_name
|
||||
self.log_tail = log_tail
|
||||
MonitorManagerMixin.__init__(self, LogMonitor, self.process_name, self.log_tail)
|
||||
|
||||
self.command_handlers = {
|
||||
'process_name': self.handle_process_name,
|
||||
'log_tail': self.handle_log_tail
|
||||
}
|
||||
|
||||
def handle_event(self, message):
|
||||
pass
|
||||
try:
|
||||
data = message['data']
|
||||
self.command_handlers[data['command']](data)
|
||||
self.reload_monitor()
|
||||
except KeyError:
|
||||
LOG.error('IGNORING MESSAGE: Invalid message received: %s', message)
|
||||
|
||||
def handle_process_name(self, data):
|
||||
self.set_monitor_args(data['process_name'], self.log_tail)
|
||||
|
||||
def handle_log_tail(self, data):
|
||||
self.set_monitor_args(self.process_name, data['log_tail'])
|
||||
|
Loading…
Reference in New Issue
Block a user