Mercurial > libervia-backend
diff src/core/log_config.py @ 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 | a836b6da2c5c |
children | 64ff259d3cbb |
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