logger

logger,第1张

#!/usr/bin/env python
# -*- encoding: utf-8 -*-

import time
from conf.conf import conf
from loguru import logger


def info_PRINT(messges):
    timestap = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    day = time.strftime("%Y-%m-%d", time.localtime())
    logger.info(messges)
    with open(file=conf.logPath + str(day) + ".log", mode="a+", encoding="utf-8") as f:
        f.write(str(timestap) + "   | INFO |    " + str(messges) + "\n")
        f.close()


def warning_PRINT(messges):
    timestap = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    day = time.strftime("%Y-%m-%d", time.localtime())
    logger.warning(messges)
    with open(file=conf.logPath + str(day) + ".log", mode="a+", encoding="utf-8") as f:
        f.write(str(timestap) + "   | WARNING |    " + str(messges) + "\n")
        f.close()

def error_PRINT(messges):
    timestap = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    day = time.strftime("%Y-%m-%d", time.localtime())
    logger.error(messges)
    with open(file=conf.logPath + str(day) + ".log", mode="a+", encoding="utf-8") as f:
        f.write(str(timestap) + "   | ERROR |  " + str(messges) + "\n")
        f.close()

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/790551.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-05
下一篇 2022-05-05

发表评论

登录后才能评论

评论列表(0条)

保存