Commits

howerton committed a10a31e

updating to handle the scenario of having both python and file loggers setup

Comments (0)

Files changed (1)

         access_logger = logging.getLogger('eventlet.wsgi.access')
         logger = logging.getLogger('eventlet.wsgi')
 
+        if not log and not logger.handlers:
+            log = sys.stderr
+        if log:
+            def write_msg(msg, extra=None):
+                if extra:
+                    log.write(log_format % extra + '\n')
+                else:
+                    log.write(msg + '\n')
+
+            if log.name == '/dev/null':
+                self.log_access = None
+                self.log_error = self.log_info = sys.stderr.write
+            else:
+                self.log_error = self.log_info = self.log_access = write_msg
+
         if logger.handlers:
             def access_wrapper(msg, extra=None):
                 msg = log_format % extra
             self.log_access = access_wrapper
             self.log_info = logger.info
             self.log_error = logger.error
-        else:
-            if not log:
-                log = sys.stderr
 
-            def write_msg(msg, extra=None):
-                if extra:
-                    log.write(log_format % extra + '\n')
-                else:
-                    log.write(msg + '\n')
-
-            if log.name == '/dev/null':
-                self.log_access = None
-                self.log_error = self.log_info = sys.stderr.write
-            else:
-                self.log_error = self.log_info = self.log_access = write_msg
+        if logger.handlers and log:
+            if log != sys.stderr:
+                self.log_info("Warning: Python and File loggers have been setup, logging will be passed only to the python loggers.")
 
         self.app = app
         self.keepalive = keepalive