zoukankan      html  css  js  c++  java
  • python 日志 logging

    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")

      

  • 相关阅读:
    c++看题
    理想化
    thin mission
    编程时 和 thinking
    tiny mission 2021 10 20
    A Magic Lamp HDU
    Poj 3370
    鸽巢原理(抽屉原理)
    Miller-Rabin质数测试
    Nim or not Nim? HDU
  • 原文地址:https://www.cnblogs.com/bianzhiwei/p/10826090.html
Copyright © 2011-2022 走看看