Skip to content

Commit 67fff52

Browse files
committed
Merge pull request #62 from d-Rickyy-b/dev
Update master from dev
2 parents af83393 + 1924ae6 commit 67fff52

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,7 @@ ENV/
9494
.git
9595
__pycache__
9696
*.db
97-
.vs
97+
.vs
98+
99+
# Keep logrotated files out of git
100+
logs/*.log*

main.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
import logging
3+
import logging.handlers
44
import os
55
import re
66
import sys
@@ -23,12 +23,16 @@
2323

2424
BOT_TOKEN = "<your_bot_token>"
2525

26-
logfile_dir_path = os.path.dirname(os.path.abspath(__file__))
27-
logfile_abs_path = os.path.join(logfile_dir_path, "logs", "bot.log")
28-
logfile_handler = logging.FileHandler(logfile_abs_path, 'a', 'utf-8')
26+
logdir_path = os.path.dirname(os.path.abspath(__file__))
27+
logfile_path = os.path.join(logdir_path, "logs", "bot.log")
28+
29+
if not os.path.exists(os.path.join(logdir_path, "logs")):
30+
os.makedirs(os.path.join(logdir_path, "logs"))
31+
32+
logfile_handler = logging.handlers.WatchedFileHandler(logfile_path, 'a', 'utf-8')
2933

3034
logger = logging.getLogger(__name__)
31-
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.DEBUG, handlers=[logfile_handler])
35+
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO, handlers=[logfile_handler])
3236

3337
if not re.match("[0-9]+:[a-zA-Z0-9\-_]+", BOT_TOKEN):
3438
logging.error("Bot token not correct - please check.")
@@ -463,3 +467,4 @@ def restart(bot, update):
463467

464468
updater.start_polling()
465469
updater.idle()
470+
logger.info("Bot started")

0 commit comments

Comments
 (0)