Check if log.txt exists before trying to open

This fixes #3
This commit is contained in:
Shivam Jha 2019-10-17 21:45:03 +05:30 committed by GitHub
parent 35f99c849f
commit fa664e6663
Signed by untrusted user: GitHub
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,8 +5,10 @@ import threading
from telegram.ext import Updater
import os
with open('log.txt', 'r+') as f:
f.truncate(0)
if os.path.exists('log.txt'):
with open('log.txt', 'r+') as f:
f.truncate(0)
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[logging.FileHandler('log.txt'), logging.StreamHandler()],