summaryrefslogtreecommitdiffstats
path: root/pym/portage.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-06-21 23:29:33 +0000
committerZac Medico <zmedico@gentoo.org>2007-06-21 23:29:33 +0000
commit9fa47cfc222dc13c9bc023c3a5730733666093cb (patch)
tree81af96288ea0573a8f084c34052c7d260ff4443f /pym/portage.py
parent4a0fd8c7bf04c0d4c1e356489487ff89afc7e2ea (diff)
downloadportage-9fa47cfc222dc13c9bc023c3a5730733666093cb.tar.gz
portage-9fa47cfc222dc13c9bc023c3a5730733666093cb.tar.bz2
portage-9fa47cfc222dc13c9bc023c3a5730733666093cb.zip
Allow per-module filtering based on loglevels in addition to the global PORTAGE_ELOG_CLASSES one, add wildcard support for loglevels (trunk r5706:5709)
svn path=/main/branches/2.1.2/; revision=6921
Diffstat (limited to 'pym/portage.py')
-rw-r--r--pym/portage.py68
1 files changed, 47 insertions, 21 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 04256010a..fb20fd0ba 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -479,40 +479,66 @@ def elog_process(cpv, mysettings):
return
# exploit listdir() file order so we process log entries in chronological order
mylogfiles.reverse()
- mylogentries = {}
- my_elog_classes = set(mysettings.get("PORTAGE_ELOG_CLASSES", "").split())
+ all_logentries = {}
for f in mylogfiles:
msgfunction, msgtype = f.split(".")
- if msgtype.upper() not in my_elog_classes \
- and msgtype.lower() not in my_elog_classes:
- continue
if msgfunction not in portage_const.EBUILD_PHASES:
writemsg("!!! can't process invalid log file: %s\n" % f,
noiselevel=-1)
continue
- if not msgfunction in mylogentries:
- mylogentries[msgfunction] = []
+ if not msgfunction in all_logentries:
+ all_logentries[msgfunction] = []
msgcontent = open(mysettings["T"]+"/logging/"+f, "r").readlines()
- mylogentries[msgfunction].append((msgtype, msgcontent))
+ all_logentries[msgfunction].append((msgtype, msgcontent))
+
+ def filter_loglevels(logentries, loglevels):
+ # remove unwanted entries from all logentries
+ rValue = {}
+ loglevels = map(str.upper, loglevels)
+ for phase in logentries:
+ for msgtype, msgcontent in logentries[phase]:
+ if msgtype.upper() in loglevels or "*" in loglevels:
+ if not rValue.has_key(phase):
+ rValue[phase] = []
+ rValue[phase].append((msgtype, msgcontent))
+ return rValue
- # in case the filters matched all messages
- if len(mylogentries) == 0:
+ my_elog_classes = set(mysettings.get("PORTAGE_ELOG_CLASSES", "").split())
+ default_logentries = filter_loglevels(all_logentries, my_elog_classes)
+
+ # in case the filters matched all messages and no module overrides exist
+ if len(default_logentries) == 0 and (not ":" in mysettings.get("PORTAGE_ELOG_SYSTEM", "")):
return
- # generate a single string with all log messages
- fulllog = ""
- for phase in portage_const.EBUILD_PHASES:
- if not phase in mylogentries:
- continue
- for msgtype,msgcontent in mylogentries[phase]:
- fulllog += "%s: %s\n" % (msgtype, phase)
- for line in msgcontent:
- fulllog += line
- fulllog += "\n"
+ def combine_logentries(logentries):
+ # generate a single string with all log messages
+ rValue = ""
+ for phase in portage_const.EBUILD_PHASES:
+ if not phase in logentries:
+ continue
+ for msgtype,msgcontent in logentries[phase]:
+ rValue += "%s: %s\n" % (msgtype, phase)
+ for line in msgcontent:
+ rValue += line
+ rValue += "\n"
+ return rValue
+
+ default_fulllog = combine_logentries(default_logentries)
# pass the processing to the individual modules
logsystems = mysettings["PORTAGE_ELOG_SYSTEM"].split()
for s in logsystems:
+ # allow per module overrides of PORTAGE_ELOG_CLASSES
+ if ":" in s:
+ s, levels = s.split(":", 1)
+ levels = levels.split(",")
+ mod_logentries = filter_loglevels(all_logentries, levels)
+ mod_fulllog = combine_logentries(mod_logentries)
+ else:
+ mod_logentries = default_logentries
+ mod_fulllog = default_fulllog
+ if len(mod_logentries) == 0:
+ continue
# - is nicer than _ for module names, so allow people to use it.
s = s.replace("-", "_")
try:
@@ -529,7 +555,7 @@ def elog_process(cpv, mysettings):
# module gets hung).
signal.alarm(60)
try:
- m.process(mysettings, cpv, mylogentries, fulllog)
+ m.process(mysettings, cpv, mod_logentries, mod_fulllog)
finally:
signal.alarm(0)
if hasattr(m, "finalize") and not m.finalize in _elog_atexit_handlers: