logger.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:odooku-compat 作者: adaptivdesign 项目源码 文件源码
def log(self, lvl, msg, *args, **kwargs):
        try:
            extra = kwargs.get("extra", None)
            if extra is not None:
                metric = extra.get(METRIC_VAR, None)
                value = extra.get(VALUE_VAR, None)
                typ = extra.get(MTYPE_VAR, None)
                if metric and value and typ:
                    if typ == GAUGE_TYPE:
                        self.gauge(metric, value)
                    elif typ == COUNTER_TYPE:
                        self.increment(metric, value)
                    elif typ == HISTOGRAM_TYPE:
                        self.histogram(metric, value)
                    else:
                        pass
        except Exception:
            logging.Logger.warning(self, "Failed to log to statsd", exc_info=True)

        if msg:
            logging.Logger.log(self, lvl, msg, *args, **kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号