From 02243958d25c5d49238ceb5e4558450eb05d6adb Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 23 Apr 2014 10:38:11 -0400 Subject: [PATCH] Avoid blank entries when acting like a file object and something does 'write('\n')' --- confluent/log.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/confluent/log.py b/confluent/log.py index 409603a1..57a48f76 100644 --- a/confluent/log.py +++ b/confluent/log.py @@ -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