import os
import logging
from logging.handlers import RotatingFileHandler
import platform

platform_ = platform.system()
is_win = is_linux = is_mac = False

if platform_ == "Windows":
    is_win = True
elif platform_ == "Linux":
    is_linux = True
elif platform_ == "Mac":
    is_mac = True


def init_logging(log_file_path=None, file_name='out.log'):
    path = log_file_path
    if not os.path.exists(path):
        os.makedirs(path)
    logging.basicConfig(
        handlers=[RotatingFileHandler(path + file_name,
                      # 设置 日子文件大小100M 超过自动换文件 maxBytes=100 * 1024 * 1024, backupCount=5, encoding='utf-8', delay=0), logging.StreamHandler()], level=logging.INFO, format='%(asctime)s.%(msecs)03d %(thread)d %(levelname)s %(module)s %(lineno)d - %(funcName)s : %(message)s', datefmt="%Y-%m-%d %H:%M:%S")

  

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。