apply additional phase filters as otherwise some messages are logged in both unmerge...
authorMarius Mauch <genone@gentoo.org>
Sat, 30 Jun 2007 11:21:26 +0000 (11:21 -0000)
committerMarius Mauch <genone@gentoo.org>
Sat, 30 Jun 2007 11:21:26 +0000 (11:21 -0000)
svn path=/main/trunk/; revision=7098

pym/portage/elog/__init__.py
pym/portage/elog/filtering.py

index cbe9f47fa0a37a924e14f170a91c2b3eda593c2a..ef040faa938ce06e3d0ba6cd18b1a447ccdab64e 100644 (file)
@@ -41,7 +41,8 @@ def _combine_logentries(logentries):
        return rValue
 
 _elog_atexit_handlers = []
-def elog_process(cpv, mysettings):
+_preserve_logentries = {}
+def elog_process(cpv, mysettings, phasefilter=None):
        ebuild_logentries = collect_ebuild_messages(os.path.join(mysettings["T"], "logging"))
        all_logentries = collect_messages()
        if all_logentries.has_key(cpv):
@@ -49,8 +50,18 @@ def elog_process(cpv, mysettings):
        else:
                all_logentries[cpv] = ebuild_logentries
 
-       my_elog_classes = set(mysettings.get("PORTAGE_ELOG_CLASSES", "").split())
+       for key in _preserve_logentries.keys():
+               if all_logentries.has_key(key):
+                       all_logentries[key] = _merge_logentries(_preserve_logentries[key], all_logentries[key])
+               else:
+                       all_logentries[key] = _preserve_logentries[key]
+               del _preserve_logentries[key]
+
+       if phasefilter != None:
+               for key in all_logentries:
+                       all_logentries[key], _preserve_logentries[key] = phasefilter(all_logentries[key])
 
+       my_elog_classes = set(mysettings.get("PORTAGE_ELOG_CLASSES", "").split())
 
        for key in all_logentries:
                default_logentries = filter_loglevels(all_logentries[key], my_elog_classes)
index e8a5430fd04cc09bd4e9ba81895d7dfc3bab5db1..b41f64e48500ff18df23e607ba641e6e18fad45e 100644 (file)
@@ -3,6 +3,8 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id: __init__.py 6458 2007-04-30 02:31:30Z genone $
 
+from portage.const import EBUILD_PHASES
+
 def filter_loglevels(logentries, loglevels):
        # remove unwanted entries from all logentries
        rValue = {}
@@ -15,3 +17,22 @@ def filter_loglevels(logentries, loglevels):
                                rValue[phase].append((msgtype, msgcontent))
        return rValue
        
+def filter_phases(logentries, phases):
+       rValue1 = {}
+       rValue2 = {}
+       phases = map(str.lower, phases)
+       for phase in logentries:
+               if phase in phases:
+                       rValue1[phase] = logentries[phase]
+               else:
+                       rValue2[phase] = logentries[phase]
+       return (rValue1, rValue2)
+
+def filter_mergephases(logentries):
+       myphases = EBUILD_PHASES[:]
+       myphases.remove("prerm")
+       myphases.remove("postrm")
+       return filter_phases(logentries, myphases)
+
+def filter_unmergephases(logentries):
+       return filter_phases(logentries, ["prerm", "postrm", "other"])