bootstrap-vz/bootstrapvz/base/remote/log.py
Anders Ingemann e271f3e49a Initial work on integration testing started.
The work consists of three parts:
* Allow for bootstrapping remotely,
  this makes it possible to run the tests
  on e.g. OSX with VirtualBox installed
* Make bootstrapping a fully automated process
  where the manifests can be generated by the tests
  and the tests can call the bootstrapper directly in python
* Create a framework wherein instances can be booted up
  using the bootstrapped images and subsequently tested
2015-04-16 22:15:17 +02:00

24 lines
500 B
Python

import logging
import pickle
class LogForwarder(logging.Handler):
def __init__(self, level=logging.NOTSET):
self.server = None
super(LogForwarder, self).__init__(level)
def set_server(self, server):
self.server = server
def emit(self, record):
if self.server is not None:
self.server.handle(pickle.dumps(record))
class LogServer(object):
def handle(self, pickled_record):
import logging
log = logging.getLogger()
record = pickle.loads(pickled_record)
log.handle(record)