mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-03-21 18:18:41 +00:00
commit
ccaeb5a142
@ -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):
|
||||||
|
@ -44,6 +44,28 @@ _indent_width = 4
|
|||||||
_console_handler = None
|
_console_handler = None
|
||||||
|
|
||||||
|
|
||||||
|
class ContextLogger(logging.Logger):
|
||||||
|
|
||||||
|
def __init__(self, name, context=None):
|
||||||
|
super(ContextLogger, self).__init__(name)
|
||||||
|
self.context = context
|
||||||
|
|
||||||
|
def warning(self, message):
|
||||||
|
if self.context:
|
||||||
|
self.context.add_event(message)
|
||||||
|
super(ContextLogger, self).warning(message)
|
||||||
|
|
||||||
|
def warn(self, message):
|
||||||
|
if self.context:
|
||||||
|
self.context.add_event(message)
|
||||||
|
super(ContextLogger, self).warn(message)
|
||||||
|
|
||||||
|
def error(self, message):
|
||||||
|
if self.context:
|
||||||
|
self.context.add_event(message)
|
||||||
|
super(ContextLogger, self).error(message)
|
||||||
|
|
||||||
|
|
||||||
def init(verbosity=logging.INFO, color=True, indent_with=4,
|
def init(verbosity=logging.INFO, color=True, indent_with=4,
|
||||||
regular_fmt='%(levelname)-8s %(message)s',
|
regular_fmt='%(levelname)-8s %(message)s',
|
||||||
verbose_fmt='%(asctime)s %(levelname)-8s %(name)10.10s: %(message)s',
|
verbose_fmt='%(asctime)s %(levelname)-8s %(name)10.10s: %(message)s',
|
||||||
@ -51,6 +73,7 @@ def init(verbosity=logging.INFO, color=True, indent_with=4,
|
|||||||
global _indent_width, _console_handler
|
global _indent_width, _console_handler
|
||||||
_indent_width = indent_with
|
_indent_width = indent_with
|
||||||
signal.log_error_func = lambda m: log_error(m, signal.logger)
|
signal.log_error_func = lambda m: log_error(m, signal.logger)
|
||||||
|
logging.setLoggerClass(ContextLogger)
|
||||||
|
|
||||||
root_logger = logging.getLogger()
|
root_logger = logging.getLogger()
|
||||||
root_logger.setLevel(logging.DEBUG)
|
root_logger.setLevel(logging.DEBUG)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user