芯片资讯
你的位置:CMOS图像传感器IC集成电路芯片-亿配芯城 > 芯片资讯 > Python自定义输出格式
Python自定义输出格式
- 发布日期:2023-12-31 13:12 点击次数:53 自定义输出格式
我们可以在之前添加的输出格式中添加其他的格式内容
import coloredlogs import logging def func_name(): # 增加了modules、funcName两个变量,分辨标识我们日志所在文件以及在哪一个函数中输入的日志 coloredlogs.install(level='DEBUG', fmt='%(asctime)s - %(module)s - %(funcName)s - %(levelname)s - %(message)s') logging.debug('debug message') logging.info('info message') logging.error('error message') logging.warning('warning message') func_name()
输出结果如下
我们增加了两个变量后,
CMOS图像传感器集成电路芯片可以方便我们后续寻找问题时就直接定位到了那个文件中的哪个函数出了问题,
电子元器件PDF资料大全CMOS图像传感器IC集成电路芯片这是不是就方便我们后面解决问题的效率。
再上面我们是直接使用了coloredlogs中的默认日志级别颜色样式,EEPROM带电可擦可编程存储器芯片大全同样的我们也可以自定义设置不同日志的显示的样色样式
import coloredlogs import logging def fun_name(): level_styles = coloredlogs.DEFAULT_LEVEL_STYLES.copy() level_styles['debug'] = {'color': 'magenta'} level_styles['info'] = {'color': 'yellow'} level_styles['error'] = {'color': 'red'} level_styles['warning'] = {'color': 'blue'} coloredlogs.install(level="DEBUG", 芯片交易网IC交易网 level_styles=level_styles, ATMEGA系列ATMEL芯片COM fmt='%(asctime)s - %(module)s - %(funcName)s - %(levelname)s - %(message)s') logging.debug('debug message') logging.info('info message') logging.error('error message') logging.warning('warning message') fun_name()
输入样式如下
相关资讯
- 如何使用Python和pandas库操作Excel文件2024-01-05
- Python条件和条件语句2024-01-04
- Python中常见的条件运算符有哪些2024-01-04
- python中while循环条件介绍2024-01-04
- 如何使用python获取和修改图像信息2024-01-04
- python定义函数与调用函数的顺序2024-01-02