fixed error with logging of utf-8 encoded logs
This commit is contained in:
parent
c8e2efc848
commit
1833986565
|
@ -39,10 +39,10 @@ class RetootBot(object):
|
||||||
time = str(datetime.datetime.now())
|
time = str(datetime.datetime.now())
|
||||||
if tb:
|
if tb:
|
||||||
message = message + " The traceback is located at " + os.path.join("logs" + time)
|
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)
|
f.write(tb)
|
||||||
line = "[" + time + "] "+ message + "\n"
|
line = "[" + time + "] "+ message + "\n"
|
||||||
with open(self.logpath, 'a') as f:
|
with open(self.logpath, 'a', encoding='utf-8') as f:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
print line,
|
print line,
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ class RetweetBot(object):
|
||||||
|
|
||||||
:param historypath: Path to the file with ID of the last retweeted
|
:param historypath: Path to the file with ID of the last retweeted
|
||||||
Tweet
|
Tweet
|
||||||
|
:param logpath: Path to the file where the log is stored
|
||||||
"""
|
"""
|
||||||
self.config = config
|
self.config = config
|
||||||
keys = self.get_api_keys()
|
keys = self.get_api_keys()
|
||||||
|
@ -84,10 +85,10 @@ class RetweetBot(object):
|
||||||
time = str(datetime.datetime.now())
|
time = str(datetime.datetime.now())
|
||||||
if tb:
|
if tb:
|
||||||
message = message + " The traceback is located at " + os.path.join("logs" + time)
|
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)
|
f.write(tb)
|
||||||
line = "[" + time + "] "+ message + "\n"
|
line = "[" + time + "] "+ message + "\n"
|
||||||
with open(self.logpath, 'a') as f:
|
with open(self.logpath, 'a', encoding='utf-8') as f:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
print line,
|
print line,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue