incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1447258 - /incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py
Date Mon, 18 Feb 2013 13:53:54 GMT
Author: jure
Date: Mon Feb 18 13:53:53 2013
New Revision: 1447258

URL: http://svn.apache.org/r1447258
Log:
#355, enhanced reuse of product environment logger, patch t355_r1446579_product_env_logging_inherit.diff
applied (from Olemis)


Modified:
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py?rev=1447258&r1=1447257&r2=1447258&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py
(original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py
Mon Feb 18 13:53:53 2013
@@ -551,29 +551,40 @@ class ProductEnvironment(Component, Comp
         """Initialize the logging sub-system."""
         from trac.log import logger_handler_factory
         logtype = self.log_type
+        logfile = self.log_file
+        format = self.log_format
+
         self.parent.log.debug("Log type '%s' for product '%s'", 
                 logtype, self.product.prefix)
+
+        # Force logger inheritance on identical configuration
+        if (logtype, logfile, format) == (self.parent.log_type, 
+                self.parent.log_file, self.parent.log_format):
+            logtype = 'inherit'
+
         if logtype == 'inherit':
-            logtype = self.parent.log_type
-            logfile = self.parent.log_file
-            format = self.parent.log_format
+            self.log = self.parent.log
+            self._log_handler = self.parent._log_handler
+            self.parent.log.warning("Inheriting parent logger for product '%s'",
+                    self.product.prefix)
         else:
-            logfile = self.log_file
-            format = self.log_format
-        if logtype == 'file' and not os.path.isabs(logfile):
-            logfile = os.path.join(self.get_log_dir(), logfile)
-        logid = 'Trac.%s.%s' % \
-                (sha1(self.parent.path).hexdigest(), self.product.prefix)
-        if format:
-            format = format.replace('$(', '%(') \
-                     .replace('%(path)s', self.path) \
-                     .replace('%(basename)s', os.path.basename(self.path)) \
-                     .replace('%(project)s', self.project_name)
-        self.log, self._log_handler = logger_handler_factory(
-            logtype, logfile, self.log_level, logid, format=format)
+            if logtype == 'file' and not os.path.isabs(logfile):
+                logfile = os.path.join(self.get_log_dir(), logfile)
+            logid = 'Trac.%s.%s' % \
+                    (sha1(self.parent.path).hexdigest(), self.product.prefix)
+            if format:
+                format = format.replace('$(', '%(') \
+                         .replace('%(path)s', self.path) \
+                         .replace('%(basename)s', os.path.basename(self.path)) \
+                         .replace('%(project)s', self.project_name)
+            self.log, self._log_handler = logger_handler_factory(
+                logtype, logfile, self.log_level, logid, format=format)
 
         from trac import core, __version__ as VERSION
-        self.log.info('-' * 32 + ' environment startup [Trac %s] ' + '-' * 32,
+        self.log.info('-' * 32 + 
+                        ' product %s environment startup [Trac %s] ' + 
+                        '-' * 32,
+                      self.product.prefix,
                       get_pkginfo(core).get('version', VERSION))
 
     def needs_upgrade(self):



Mime
View raw message