forked from Brynkr/CamelBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.py
More file actions
25 lines (18 loc) · 669 Bytes
/
Logger.py
File metadata and controls
25 lines (18 loc) · 669 Bytes
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
import discord
import datetime
from enum import Enum
import Constants
class LoggerFlags(Enum):
NOTICE = 0
WARNING = 1
ERROR = 2
'''Logging functionality'''
class Logger:
def __init__(self, filename=Constants.LOG_FILE):
self.log_file = open(filename, "w")
#[PRIORITY] Date | time | message.content | Server:Channel | User
def log_to_file(message, logger_flag=LoggerFlags.NOTICE):
now = datetime.datetime.now()
log_msg = '[' + logger_flag + '] ' + now + ' | ' + message.content \
+ ' | ' + message.server.name + ':' + message.channel.name + ' | ' + message.author.name
print(log_msg, file=log_file)