2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-28 20:39:40 +00:00

Start logging what would be stdout and stderr if not daemonized

This commit is contained in:
jbjohnso 2014-04-23 10:06:31 -04:00
parent 2db5004c54
commit 0cb5b4370b
2 changed files with 17 additions and 0 deletions

View File

@ -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")

View File

@ -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():