python logging usage

when you use some third part library,you want to print out these libraries debug info may help you dailogous,code as follows:

import logging
from urllib3.connectionpool import log
console = logging.StreamHandler()

console.setLevel(logging.INFO)

formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s")

console.setFormatter(formatter)

log.addHandler(console)

reference:http://blog.sina.com.cn/s/blog_51294ca50100gc3x.html

你可能感兴趣的:(logging)