diff options
-rw-r--r-- | pym/_emerge/Scheduler.py | 4 | ||||
-rw-r--r-- | pym/portage/elog/__init__.py | 22 |
2 files changed, 19 insertions, 7 deletions
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 1e05aac0f..7e0c35f89 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -1108,7 +1108,7 @@ class Scheduler(PollScheduler): pkg_queue = self._pkg_queue failed_pkgs = self._failed_pkgs portage.locks._quiet = self._background - portage.elog._emerge_elog_listener = self._elog_listener + portage.elog.add_listener(self._elog_listener) rval = os.EX_OK try: @@ -1116,7 +1116,7 @@ class Scheduler(PollScheduler): finally: self._main_loop_cleanup() portage.locks._quiet = False - portage.elog._emerge_elog_listener = None + portage.elog.remove_listener(self._elog_listener) if failed_pkgs: rval = failed_pkgs[-1].returncode diff --git a/pym/portage/elog/__init__.py b/pym/portage/elog/__init__.py index 1ebc027c5..7bd567cee 100644 --- a/pym/portage/elog/__init__.py +++ b/pym/portage/elog/__init__.py @@ -56,11 +56,23 @@ def _load_mod(name): _elog_mod_imports[name] = m return m -_emerge_elog_listener = None +_elog_listeners = [] +def add_listener(listener): + ''' + Listeners should accept four arguments: settings, key, logentries and logtext + ''' + _elog_listeners.append(listener) + +def remove_listener(listener): + ''' + Remove previously added listener + ''' + _elog_listeners.remove(listener) + _elog_atexit_handlers = [] _preserve_logentries = {} def elog_process(cpv, mysettings, phasefilter=None): - global _elog_atexit_handlers, _emerge_elog_listener, _preserve_logentries + global _elog_atexit_handlers, _preserve_logentries logsystems = mysettings.get("PORTAGE_ELOG_SYSTEM","").split() for s in logsystems: @@ -123,9 +135,9 @@ def elog_process(cpv, mysettings, phasefilter=None): default_fulllog = _combine_logentries(default_logentries) - if _emerge_elog_listener is not None: - _emerge_elog_listener(mysettings, str(key), - default_logentries, default_fulllog) + # call listeners + for listener in _elog_listeners: + listener(mysettings, str(key), default_logentries, default_fulllog) # pass the processing to the individual modules for s, levels in logsystems.iteritems(): |