-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (24 loc) · 907 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import logging
from discord_handler import DiscordHandler
def setup_logging():
logger = logging.getLogger()
logger.setLevel(logging.INFO)
# Create handlers
c_handler = logging.StreamHandler()
f_handler = logging.FileHandler('application.log', encoding='utf-8')
# Set levels for handlers (optional)
c_handler.setLevel(logging.INFO)
f_handler.setLevel(logging.INFO)
# Create formatter and add it to the handlers
formatter = logging.Formatter('[%(asctime)s] [%(levelname)s] %(message)s')
c_handler.setFormatter(formatter)
f_handler.setFormatter(formatter)
# Add handlers to the logger
logger.addHandler(c_handler)
logger.addHandler(f_handler)
logging.info('Logging is set up.')
if __name__ == "__main__":
setup_logging()
logging.info('Application is starting.')
discord_handler = DiscordHandler()
discord_handler.run_bot()