new log format

This commit is contained in:
dan63047 2020-06-10 20:42:30 +03:00
parent 1252c9ee7f
commit 1332d8aaf4
1 changed files with 7 additions and 5 deletions

View File

@ -22,17 +22,19 @@ try:
except:
log_path = 'bot.log'
handler = logging.FileHandler(log_path, 'w', 'utf-8')
handler.setFormatter(logging.Formatter('[%(asctime)s][%(levelname)s] %(message)s'))
handler.setFormatter(logging.Formatter('%(message)s'))
root_logger.addHandler(handler)
def log(warning, text):
if warning:
logging.warning(text)
msg = "[" + str(datetime.datetime.now()) + "] [WARNING] " + text
logging.warning(msg)
print(msg)
debug_array['logger_warnings'] += 1
print("[" + str(datetime.datetime.now()) + "] [WARNING] " + text)
else:
logging.info(text)
print("[" + str(datetime.datetime.now()) + "] " + text)
msg = "[" + str(datetime.datetime.now()) + "] " + text
logging.info(msg)
print(msg)
log(False, "Script started")