当前位置:网站首页>Basic use of logging

Basic use of logging

2022-07-26 10:56:00 Yasso won't blow

import logging
''' basicConfig() Method  level  The lowest level  datefmt  Time format  format  Text format in the log  %()s  Fixed format  filename  Save filename  '''

#
# ''' By default, only info Log above level '''
#logging.basicConfig(level=logging.DEBUG)
# logging.debug("debug The level of log :  Print all the logs , Details , It's usually only a diagnostic problem ")
#
# logging.info("info The level of log :  Print info,warning,error,critical Level of logging , Make sure everything works as expected ")
#
# logging.warning("warning The level of log :  Print warning,error,critical Level of logging , A trace "
# " Image indication , Something unexpected happened , Or show some problems in the near future ( for example . Low disk space ”), The software works as expected ")
#
# logging.error("error The level of log :  Print error,critical Level of logging , More serious problem , The software doesn't perform some functions ")
#
# logging.critical("critical The level of log :  Print critical Level , A serious mistake , This indicates that the program itself may not continue to run ")


# ''' Set log display variables '''
#
# name=" millet "
# age=18
# logging.basicConfig(level=logging.DEBUG)
#
# ''' This debug Use lowercase , An error will be reported in words  '''
# logging.debug(" full name {}, Age {}".format(name,age))
# logging.debug(" full name %s, Age %d",name,age)
''' Set the log display content '''
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(name)s %(levelname)s %(module)s: %(message)s'
                    ,datefmt='%Y-%m-%d %H:%M:%S')
logging.debug(' Set text output content ')
logging.debug('asctime Time ')
logging.debug('name name ')
logging.debug("levelname Current log level ")
logging.debug("module Current location ")
logging.debug("message Text information ")

原网站

版权声明
本文为[Yasso won't blow]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/207/202207261049593031.html