2 Star 0 Fork 0

shine_forever / pyTest

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
log.py 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
shine_forever 提交于 2014-02-21 15:45 . 20140221
#! /usr/bin/env python
#coding:utf-8
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
datefmt='%a, %d %b %Y %H:%M:%S',
filename='/home/guolt/logTest.log',
filemode='a')
#################################################################################################
#定义一个StreamHandler,将INFO级别或更高的日志信息打印到标准错误,并将其添加到当前的日志处理对象#
console = logging.StreamHandler()
console.setLevel(logging.INFO)
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
#################################################################################################
test='guolt'
logging.debug('This is debug message: %s' %test)
logging.info('This is info message')
logging.warning('This is warning message')
logging.debug('#'*10)
Python
1
https://gitee.com/shine_forever/pyTest.git
git@gitee.com:shine_forever/pyTest.git
shine_forever
pyTest
pyTest
master

搜索帮助