mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-20 11:58:55 +00: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:
parent
47d883de09
commit
8dd1e6636c
@ -286,13 +286,13 @@ class Executor(object):
|
||||
|
||||
self.logger.info('Installing instrumentation')
|
||||
for instrument in config_manager.get_instruments(self.target_manager.target):
|
||||
instrumentation.install(instrument)
|
||||
instrumentation.install(instrument, context)
|
||||
instrumentation.validate()
|
||||
|
||||
self.logger.info('Installing result processors')
|
||||
pm = ProcessorManager()
|
||||
for proc in config_manager.get_processors():
|
||||
pm.install(proc)
|
||||
pm.install(proc, context)
|
||||
pm.validate()
|
||||
|
||||
self.logger.info('Starting run')
|
||||
@ -342,6 +342,7 @@ class Runner(object):
|
||||
|
||||
def __init__(self, context, pm):
|
||||
self.logger = logging.getLogger('runner')
|
||||
self.logger.context = context
|
||||
self.context = context
|
||||
self.pm = pm
|
||||
self.output = self.context.output
|
||||
|
@ -287,7 +287,7 @@ class ManagedCallback(object):
|
||||
_callbacks = []
|
||||
|
||||
|
||||
def install(instrument):
|
||||
def install(instrument, context):
|
||||
"""
|
||||
This will look for methods (or any callable members) with specific names
|
||||
in the instrument and hook them up to the corresponding signals.
|
||||
@ -328,6 +328,7 @@ def install(instrument):
|
||||
_callbacks.append(mc)
|
||||
signal.connect(mc, SIGNAL_MAP[attr_name], priority=priority.value)
|
||||
|
||||
instrument.logger.context = context
|
||||
installed.append(instrument)
|
||||
|
||||
|
||||
|
@ -57,6 +57,7 @@ class Job(object):
|
||||
def initialize(self, context):
|
||||
self.logger.info('Initializing job {} [{}]'.format(self.id, self.iteration))
|
||||
with signal.wrap('WORKLOAD_INITIALIZED', self, context):
|
||||
self.workload.logger.context = context
|
||||
self.workload.initialize(context)
|
||||
self.set_status(Status.PENDING)
|
||||
context.update_job_state(self)
|
||||
|
@ -33,10 +33,11 @@ class ProcessorManager(object):
|
||||
self.logger = logging.getLogger('processor')
|
||||
self.processors = []
|
||||
|
||||
def install(self, processor):
|
||||
def install(self, processor, context):
|
||||
if not isinstance(processor, ResultProcessor):
|
||||
processor = self.loader.get_result_processor(processor)
|
||||
self.logger.debug('Installing {}'.format(processor.name))
|
||||
processor.logger.context = context
|
||||
self.processors.append(processor)
|
||||
|
||||
def validate(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user