#-*- coding:utf-8 -*-
import logging,time,os
# 配置日志信息
timestr = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
lib_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../logs'))
# print lib_path
logging.basicConfig(encode="utf-8" , encoding = "UTF-8",level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M',
filename=lib_path+'/'+timestr+'.log',
filemode='w')
# 定义一个Handler打印INFO及以上级别的日志到sys.stderr
console = logging.StreamHandler()
console.setLevel(logging.INFO)
# 设置日志打印格式
formatter = logging.Formatter('%(levelname)-8s %(message)s')
console.setFormatter(formatter)
# 将定义好的console日志handler添加到root logger
logging.getLogger('').addHandler(console)
logger = logging.getLogger('log')
# logger1.info('Jackdaws love my big sphinx of quartz.')
# logger1.debug('This is a test')
# logger1.warning('This is a warning')
# logger1.error('Thisi a error')
# logger1 = logging.getLogger('myapp.area1')
# logger1.debug('Quick zephyrs blow, vexing daft Jim.')
# logger1.info('How quickly daft jumping zebras vex.')
# logger2.warning('Jail zesty vixen who grabbed pay from quack.')
# logger2.error('The five boxing wizards jump quickly.')