符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
这篇文章将为大家详细讲解有关python中logging添加filter的示例分析,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
发展壮大离不开广大客户长期以来的信赖与支持,我们将始终秉承“诚信为本、服务至上”的服务理念,坚持“二合一”的优良服务模式,真诚服务每家企业,认真做好每个细节,不断完善自我,成就企业,实现共赢。行业涉及iso认证等,在成都网站建设、全网整合营销推广、WAP手机网站、VI设计、软件开发等项目上具有丰富的设计经验。例子一
def filter(self, record): """Our custom record filtering logic. Built-in filtering logic (via logging.Filter) is too limiting. """ if not self.filters: return True matched = False rname = record.name # shortcut for name in self.filters: if rname == name or rname.startswith(name+'.'): matched = True return matched
例子二
def _create_log_handlers(stream): """Create and return a default list of logging.Handler instances. Format WARNING messages and above to display the logging level, and messages strictly below WARNING not to display it. Args: stream: See the configure_logging() docstring. """ # Handles logging.WARNING and above. error_handler = logging.StreamHandler(stream) error_handler.setLevel(logging.WARNING) formatter = logging.Formatter("%(levelname)s: %(message)s") error_handler.setFormatter(formatter) # Create a logging.Filter instance that only accepts messages # below WARNING (i.e. filters out anything WARNING or above). non_error_filter = logging.Filter() # The filter method accepts a logging.LogRecord instance. non_error_filter.filter = lambda record: record.levelno < logging.WARNING non_error_handler = logging.StreamHandler(stream) non_error_handler.addFilter(non_error_filter) formatter = logging.Formatter("%(message)s") non_error_handler.setFormatter(formatter) return [error_handler, non_error_handler]
例子三
def _default_handlers(stream): """Return a list of the default logging handlers to use. Args: stream: See the configure_logging() docstring. """ # Create the filter. def should_log(record): """Return whether a logging.LogRecord should be logged.""" # FIXME: Enable the logging of autoinstall messages once # autoinstall is adjusted. Currently, autoinstall logs # INFO messages when importing already-downloaded packages, # which is too verbose. if record.name.startswith("webkitpy.thirdparty.autoinstall"): return False return True logging_filter = logging.Filter() logging_filter.filter = should_log # Create the handler. handler = logging.StreamHandler(stream) formatter = logging.Formatter("%(name)s: [%(levelname)s] %(message)s") handler.setFormatter(formatter) handler.addFilter(logging_filter) return [handler]
关于“python中logging添加filter的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。