From 0cb5b4370b277dc7a7f0bf998cf3e7aa7e50e35e Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 23 Apr 2014 10:06:31 -0400 Subject: [PATCH] Start logging what would be stdout and stderr if not daemonized --- confluent/log.py | 14 ++++++++++++++ confluent/main.py | 3 +++ 2 files changed, 17 insertions(+) diff --git a/confluent/log.py b/confluent/log.py index 064bff77..7875ab1c 100644 --- a/confluent/log.py +++ b/confluent/log.py @@ -220,6 +220,20 @@ class Logger(object): termstate = 0 return textdata, termstate + def write(self, data): + """Write plain text to log + + This is intended so that a log object may be used to replace a + normal file object with a loss of capability. For example, + sys.stdout = logobject + + :param data: data to log + """ + self.log(data) + + def flush(self): + pass + def log(self, logdata=None, ltype=None, event=0, eventdata=None): if type(logdata) not in (str, unicode, dict): raise Exception("Unsupported logdata") diff --git a/confluent/main.py b/confluent/main.py index d6646a90..f7fd705e 100644 --- a/confluent/main.py +++ b/confluent/main.py @@ -28,6 +28,7 @@ import atexit import confluent.consoleserver as consoleserver import confluent.pluginapi as pluginapi import confluent.httpapi as httpapi +import confluent.log as log import confluent.sockapi as sockapi import eventlet #import eventlet.backdoor as backdoor @@ -53,6 +54,8 @@ def _daemonize(): os.open(os.devnull, os.O_RDWR) os.dup2(0, 1) os.dup2(0, 2) + sys.stdout = log.logger('stdout') + sys.stderr = log.logger('stderr') def _updatepidfile():