Python内置logging模块

最近调试Python代码比较多,发现logging模块很好用。

我的用法如下:

import logging

logging.basicConfig(level=logging.INFO, 
format='%(asctime)s - %(filename)s [line: %(lineno)d] - %(message)s')
#logging.disable(logging.CRITICAL)

logging.info('your message')

 需要取消注释时去掉代码中的#即可。

猜你喜欢

转载自www.cnblogs.com/lyg-blog/p/8969913.html