StructuredPrint.py
627 Bytes
# coding=utf-8
#author: 4N
#createtime: 2021/5/17
#email: nheweijun@sina.com
import datetime
import os
class StructurePrint:
log_file = os.path.join(os.path.dirname(
os.path.dirname(
os.path.dirname(
os.path.dirname(
os.path.realpath(__file__))))), "logs", "log.txt")
@classmethod
def print(cls,mes, type="info"):
with open(cls.log_file,"a",encoding="utf-8") as f:
message = "[{}] {} {}\n".format(type.upper(), datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), mes)
f.write(message)