From: Menno Smits Date: Tue, 11 Aug 2015 10:46:09 +0000 (+1200) Subject: Make debug logging handle bytes better X-Git-Tag: 1.0.0~1^2~44 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=e20123b5f692c79ac5157e709c1f947dbd578a31;p=imapclient.git Make debug logging handle bytes better Avoid issues with 8-bit data. --- diff --git a/imapclient/imapclient.py b/imapclient/imapclient.py index cfb371a..c959db3 100644 --- a/imapclient/imapclient.py +++ b/imapclient/imapclient.py @@ -1077,7 +1077,10 @@ class IMAPClient(object): debug = property(__debug_get, __debug_set) def _log(self, text): - self.log_file.write('%s %s\n' % (datetime.now().strftime('%M:%S.%f'), text)) + timestamp = datetime.now().strftime('%M:%S.%f') + if isinstance(text, binary_type): + text = repr(text)[1:-1] + self.log_file.write(timestamp + ' ' + text + '\n') self.log_file.flush() def _normalise_folder(self, folder_name):