Make elog_process() pre-load log modules that it can be called
authorZac Medico <zmedico@gentoo.org>
Thu, 29 Nov 2007 09:35:50 +0000 (09:35 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 29 Nov 2007 09:35:50 +0000 (09:35 -0000)
just for that purpose. (trunk r8751)

svn path=/main/branches/2.1.2/; revision=8752

pym/portage.py

index 88f0b3fb4dbd493b9238a3bcb6cfe57d3ba2ac4b..c1527a4d42e4d2298bb7a976f5246d4a224fc662 100644 (file)
@@ -495,6 +495,25 @@ class digraph:
 _elog_mod_imports = {}
 _elog_atexit_handlers = []
 def elog_process(cpv, mysettings):
+
+       global _elog_mod_imports
+       logsystems = mysettings.get("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(",")
+               # - is nicer than _ for module names, so allow people to use it.
+               s = s.replace("-", "_")
+               try:
+                       logmodule = __import__("elog_modules.mod_"+s)
+                       m = _elog_mod_imports.get(logmodule)
+                       if m is None:
+                               m = getattr(logmodule, "mod_"+s)
+                               _elog_mod_imports[logmodule] = m
+               except ImportError:
+                       pass
+
        mylogfiles = listdir(mysettings["T"]+"/logging/")
        # shortcut for packages without any messages
        if len(mylogfiles) == 0: