python的logging模块

logger模块的三项任务:

1):像应用程序提供接口,发送log message。

2):决定执行那个log 动作==》通过filter。

3):将log message发送给注册的Handlers。

常用的函数:

logger.setLevel()  logger要处理的msg的level >= 设置的值。

Logger.debug()Logger.info()Logger.warning()Logger.error(), and Logger.critical() 用于产生msg,就是一个格式化的字符串。 **kwargs中的exc_info参数决定是否是“打印”出exception信息。

Logger.exception() 与上面的不同在于会打印出 stace trace 信息。

Logger.log()产生可以自己定制level的msg。

getLogger()返回一个logger实例,如果不给出名字就叫root,如果多次用用一个名字call这个函数会返回同一个实例。

下面这段不懂:

Loggers that are further down in the hierarchical list are children of loggers higher up in the list. For example, given a logger with a name of foo, loggers with names of foo.barfoo.bar.baz, and foo.bam are all descendants of foo.

logger有一个默认的等级,如果不给出就继承自父类。等级决定logger向它的handler传递的event

Handler.setLevel()和logger.setLevel() 的不同在于一个决定发送出神马级别的msg一个决定处理什么级别的msg。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值