fixed error with logging of utf-8 encoded logs

This commit is contained in:
b3yond 2017-07-25 15:00:57 +02:00
parent c8e2efc848
commit 1833986565
2 changed files with 5 additions and 4 deletions

View file

@ -39,10 +39,10 @@ class RetootBot(object):
time = str(datetime.datetime.now())
if tb:
message = message + " The traceback is located at " + os.path.join("logs" + time)
with open(os.path.join("logs", time), 'w+') as f:
with open(os.path.join("logs", time, encoding='utf-8'), 'w+') as f:
f.write(tb)
line = "[" + time + "] "+ message + "\n"
with open(self.logpath, 'a') as f:
with open(self.logpath, 'a', encoding='utf-8') as f:
f.write(line)
print line,

View file

@ -29,6 +29,7 @@ class RetweetBot(object):
:param historypath: Path to the file with ID of the last retweeted
Tweet
:param logpath: Path to the file where the log is stored
"""
self.config = config
keys = self.get_api_keys()
@ -84,10 +85,10 @@ class RetweetBot(object):
time = str(datetime.datetime.now())
if tb:
message = message + " The traceback is located at " + os.path.join("logs" + time)
with open(os.path.join("logs", time), 'w+') as f:
with open(os.path.join("logs", time, encoding='utf-8'), 'w+') as f:
f.write(tb)
line = "[" + time + "] "+ message + "\n"
with open(self.logpath, 'a') as f:
with open(self.logpath, 'a', encoding='utf-8') as f:
f.write(line)
print line,