1 Star 0 Fork 0

chilled/official_restful

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
function_logging.py 908 Bytes
一键复制 编辑 原始数据 按行查看 历史
chilled 提交于 2021-07-11 23:07 . 'init'
# -*- coding: utf-8 -*-
# @Time : 2021/7/11 17:33
# @Author : Dong
# @File : function_logging.py
import logging
import logging.handlers
logger = logging.getLogger("__name__")
# 标准输出
handler1 = logging.StreamHandler()
# 输出到文件
handler2 = logging.FileHandler(filename="test.txt")
logger.setLevel(logging.DEBUG)
handler1.setLevel(logging.WARNING)
handler2.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(asctime)s %(name)s %(levelname)s %(message)s")
handler1.setFormatter(formatter)
# handler2.setFormatter(formatter)
handler2 = logging.handlers.RotatingFileHandler('test.txt',mode='W',maxBytes=500,backupCount=3)
logger.addHandler(handler1)
logger.addHandler(handler2)
logger.debug('This is debug message.')
logger.info('This is info message.')
logger.warning('This is warning message.')
logger.error('This is error message.')
logger.critical('This is critical message.')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chilled/official_restful.git
git@gitee.com:chilled/official_restful.git
chilled
official_restful
official_restful
master

搜索帮助