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

Avoid blank entries when acting like a file object and something does 'write('\n')'

This commit is contained in:
jbjohnso 2014-04-23 10:38:11 -04:00
parent bd3f6a2f42
commit 02243958d2

View File

@ -170,8 +170,9 @@ class Logger(object):
else:
textrecord = textdate + data + ']'
else:
if not data.endswith('\n'):
textrecord = textdate + data + '\n'
textrecord = textdate + data
if not textrecord.endswith('\n'):
textrecord += '\n'
self.textfile.write(textrecord)
fcntl.flock(self.textfile, fcntl.LOCK_UN)
fcntl.flock(self.binfile, fcntl.LOCK_EX)
@ -230,7 +231,8 @@ class Logger(object):
:param data: data to log
"""
self.log(data)
if data != '\n': # 'print' likes to do '\n' by itself, skip that
self.log(data)
def flush(self):
pass