baseimage-tutorial-framework/tfw/components/frontend/console_logs_handler.py

20 lines
476 B
Python
Raw Normal View History

import logging
LOG = logging.getLogger(__name__)
class ConsoleLogsHandler:
keys = ['process.log.new']
def __init__(self, *, stream):
self.stream = stream
def handle_event(self, message, connector):
try:
connector.send_message({
'key': 'console.write',
'value': message[self.stream]
})
except KeyError:
LOG.error('Invalid %s message received: %s', self.keys, message)