summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMounir Lamouri <volkmar@gentoo.org>2009-08-16 21:22:34 +0000
committerMounir Lamouri <volkmar@gentoo.org>2009-08-16 21:22:34 +0000
commit95b6068670e0248feb5bf86593f840ae81a4c757 (patch)
treeb0e4ddaaf1b1ec3a9cf27d74e28305f137baee51
parent2aa5871b1a92d6224b6a28bb7c30ea931d0f5b72 (diff)
downloadportage-95b6068670e0248feb5bf86593f840ae81a4c757.tar.gz
portage-95b6068670e0248feb5bf86593f840ae81a4c757.tar.bz2
portage-95b6068670e0248feb5bf86593f840ae81a4c757.zip
Use a clean listener system for portage.elog instead of _emerge_elog_listener
svn path=/main/trunk/; revision=14071
-rw-r--r--pym/_emerge/Scheduler.py4
-rw-r--r--pym/portage/elog/__init__.py22
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():