zoukankan      html  css  js  c++  java
  • 【Python】【日志】

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    """
    @Time    :2021/9/20 17:06
    @Author  :维斯
    @File    :log.py
    @Version :1.0
    @Function:
    """
    import logging.config
    
    
    class MyLog:
        @staticmethod
        def get():
            log = {
                'version': 1,
                'disable_existing_loggers': False,
                'formatters': {
                    'default': {
                        'format': '%(asctime)s %(levelname)s %(name)s %(message)s'
                    },
                },
                'handlers': {
                    'file': {
                        'class': 'logging.handlers.TimedRotatingFileHandler',
                        'level': 'DEBUG',
                        'formatter': 'default',
                        'filename': 'log',
                        'when': 'D',  # 分割单位 S-秒;M-分;H-小时;D-天;W{0-6}-周(0-6为周一到周六,0表示周一)
                        'encoding': 'utf-8',
                    },
                },
                'root': {
                    'handlers': ['file'],
                    'level': 'INFO',
                },
            }
    
            return logging.getLogger(logging.config.dictConfig(log))
    
    
    if __name__ == '__main__':
        MyLog.get().info('info')
        MyLog.get().debug('debug')
        MyLog.get().warning('warning')
        MyLog.get().error('error')
    如果忍耐算是坚强 我选择抵抗 如果妥协算是努力 我选择争取
  • 相关阅读:
    Heavy Transportation POJ
    Frogger POJ
    CODEFORCES 25E Test
    POJ
    POJ-2777
    [ZJOI2008]骑士
    POJ
    POJ
    [USACO12FEB]Nearby Cows
    [HAOI2009]毛毛虫
  • 原文地址:https://www.cnblogs.com/danhuai/p/15317972.html
Copyright © 2011-2022 走看看