1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-06-20 07:16:11 +01:00

framework: set context for loggers

Set context for the loggers of the Runner, the workloads and the
installed instruments and processors. Errors/warnings logged by these
entities will be automatically added as events.
This commit is contained in:
Sergei Trofimov
2017-10-23 12:25:10 +01:00
parent 47d883de09
commit 8dd1e6636c
4 changed files with 8 additions and 4 deletions

@ -286,13 +286,13 @@ class Executor(object):
self.logger.info('Installing instrumentation') self.logger.info('Installing instrumentation')
for instrument in config_manager.get_instruments(self.target_manager.target): for instrument in config_manager.get_instruments(self.target_manager.target):
instrumentation.install(instrument) instrumentation.install(instrument, context)
instrumentation.validate() instrumentation.validate()
self.logger.info('Installing result processors') self.logger.info('Installing result processors')
pm = ProcessorManager() pm = ProcessorManager()
for proc in config_manager.get_processors(): for proc in config_manager.get_processors():
pm.install(proc) pm.install(proc, context)
pm.validate() pm.validate()
self.logger.info('Starting run') self.logger.info('Starting run')
@ -342,6 +342,7 @@ class Runner(object):
def __init__(self, context, pm): def __init__(self, context, pm):
self.logger = logging.getLogger('runner') self.logger = logging.getLogger('runner')
self.logger.context = context
self.context = context self.context = context
self.pm = pm self.pm = pm
self.output = self.context.output self.output = self.context.output

@ -287,7 +287,7 @@ class ManagedCallback(object):
_callbacks = [] _callbacks = []
def install(instrument): def install(instrument, context):
""" """
This will look for methods (or any callable members) with specific names This will look for methods (or any callable members) with specific names
in the instrument and hook them up to the corresponding signals. in the instrument and hook them up to the corresponding signals.
@ -328,6 +328,7 @@ def install(instrument):
_callbacks.append(mc) _callbacks.append(mc)
signal.connect(mc, SIGNAL_MAP[attr_name], priority=priority.value) signal.connect(mc, SIGNAL_MAP[attr_name], priority=priority.value)
instrument.logger.context = context
installed.append(instrument) installed.append(instrument)

@ -57,6 +57,7 @@ class Job(object):
def initialize(self, context): def initialize(self, context):
self.logger.info('Initializing job {} [{}]'.format(self.id, self.iteration)) self.logger.info('Initializing job {} [{}]'.format(self.id, self.iteration))
with signal.wrap('WORKLOAD_INITIALIZED', self, context): with signal.wrap('WORKLOAD_INITIALIZED', self, context):
self.workload.logger.context = context
self.workload.initialize(context) self.workload.initialize(context)
self.set_status(Status.PENDING) self.set_status(Status.PENDING)
context.update_job_state(self) context.update_job_state(self)

@ -33,10 +33,11 @@ class ProcessorManager(object):
self.logger = logging.getLogger('processor') self.logger = logging.getLogger('processor')
self.processors = [] self.processors = []
def install(self, processor): def install(self, processor, context):
if not isinstance(processor, ResultProcessor): if not isinstance(processor, ResultProcessor):
processor = self.loader.get_result_processor(processor) processor = self.loader.get_result_processor(processor)
self.logger.debug('Installing {}'.format(processor.name)) self.logger.debug('Installing {}'.format(processor.name))
processor.logger.context = context
self.processors.append(processor) self.processors.append(processor)
def validate(self): def validate(self):