changeset 1116:ee450d7c88a7

core (logging): logging is added to stdout in nodaemon mode (it was already the case in debug mode)
author Goffi <goffi@goffi.org>
date Thu, 21 Aug 2014 02:14:24 +0200
parents b56374a1f6d6
children 6053fb8a6466
files src/core/log_config.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/log_config.py	Wed Aug 20 23:45:21 2014 +0200
+++ b/src/core/log_config.py	Thu Aug 21 02:14:24 2014 +0200
@@ -187,10 +187,15 @@
         addObserver = self.twisted_log.addObserver
 
         if C.LOG_OPT_OUTPUT_DEFAULT in log.handlers:
-            # default output is already managed, we just add output to stdout if we are in debug mode
-            from twisted.internet import defer
-            if defer.Deferred.debug:
-               addObserver(self.twisted_log.FileLogObserver(sys.stdout).emit)
+            # default output is already managed, we just add output to stdout if we are in debug or nodaemon mode
+
+            # XXX: this hack is to know if we are in debug or nodaemon mode
+            #      any better method welcomed
+            from twisted.scripts import twistd
+            options = twistd.ServerOptions()
+            options.parseOptions()
+            if options.get('nodaemon', False) or options.get('debug', False):
+                addObserver(self.twisted_log.FileLogObserver(sys.stdout).emit)
         else:
             # \\default is not in the output, so we remove current observers
             self.cleared_observers = self.log_publisher.observers