logging

作者: shuff1e | 来源:发表于2018-03-20 22:09 被阅读4次
    Level Numeric value
    CRITICAL 50
    ERROR 40
    WARNING 30
    INFO 20
    DEBUG 10
    NOTSET 0
    [root@shuffle-dev py_test]$ vim log.py
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    import logging
    
    FORMAT='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    logging.basicConfig(level=logging.INFO,format=FORMAT)                                                                              
    logger=logging.getLogger(__name__)
    
    logger.info("Start print log")
    
    logger.setLevel(30)
    logger.info("start print log")
    logger.warning("Something may fail")
    
    [root@shuffle-dev py_test]$ ./log.py  
    2018-03-04 10:56:10,430 - __main__ - INFO - Start print log
    2018-03-04 10:56:10,430 - __main__ - WARNING - Something may fail
    

    相关文章

      网友评论

          本文标题:logging

          本文链接:https://www.haomeiwen.com/subject/zbeffftx.html