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

svn path=/main/trunk/; revision=8751

pym/portage/elog/__init__.py

index c68fedca0d4a0bdf4d0faada24712a2f09ac21bf..d3e333534384ef693a6d77e1eb48741137e5c66b 100644 (file)
@@ -46,6 +46,27 @@ _elog_mod_imports = {}
 _elog_atexit_handlers = []
 _preserve_logentries = {}
 def elog_process(cpv, mysettings, phasefilter=None):
+
+       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:
+                       name = "portage.elog.mod_" + s
+                       m = _elog_mod_imports.get(name)
+                       if m is None:
+                               m = __import__(name)
+                               for comp in name.split(".")[1:]:
+                                       m = getattr(m, comp)
+                               _elog_mod_imports[name] = m
+               except ImportError:
+                       pass
+
        ebuild_logentries = collect_ebuild_messages(os.path.join(mysettings["T"], "logging"))
        all_logentries = collect_messages()
        if all_logentries.has_key(cpv):