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: except:
log_path = 'bot.log' log_path = 'bot.log'
handler = logging.FileHandler(log_path, 'w', 'utf-8') 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) root_logger.addHandler(handler)
def log(warning, text): def log(warning, text):
if warning: if warning:
logging.warning(text) msg = "[" + str(datetime.datetime.now()) + "] [WARNING] " + text
logging.warning(msg)
print(msg)
debug_array['logger_warnings'] += 1 debug_array['logger_warnings'] += 1
print("[" + str(datetime.datetime.now()) + "] [WARNING] " + text)
else: else:
logging.info(text) msg = "[" + str(datetime.datetime.now()) + "] " + text
print("[" + str(datetime.datetime.now()) + "] " + text) logging.info(msg)
print(msg)
log(False, "Script started") log(False, "Script started")