6 Commits

Author SHA1 Message Date
RTAkland
4ca0b9afe9 feat: added log level 2021-12-18 17:12:57 +08:00
RTAkland
3dc41d32c9 feat: fixed a bug 2021-12-18 17:12:13 +08:00
RTAkland
c8a6f4fbfe feat: added log level 2021-12-18 17:10:33 +08:00
RTAkland
33bf556ed2 feat: added a log info 2021-12-18 17:03:36 +08:00
RTAkland
76e448ffa5 feat: update README.md 2021-12-18 10:23:39 +08:00
RTAkland
1899c24d62 feat: update README.md 2021-12-18 08:42:28 +08:00
6 changed files with 35 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
<p align="center">
<a href="https://github.com/MarkusJoe/QWeather">
<img src="https://img.shields.io/badge/Python-V3.10-blue.svg" alt="PythonVersion">
<img src="https://img.shields.io/badge/release-V3.0.0-green.svg" alt="QWeatherVersion">
<img src="https://img.shields.io/badge/Python-3.10.x-blue.svg" alt="PythonVersion">
<img src="https://img.shields.io/badge/release-3.0.1b-green.svg" alt="QWeatherVersion">
<img src="https://img.shields.io/badge/LINCESE-Apache2.0-orange.svg" alt="LICENSE">
</a>
</p>
@@ -16,7 +16,8 @@
</div>
<div align="center">
<b><i>当前分支版本为重构后的版本重构前版本请在before分支中查看<br>(重构前版本不再更新,最新版本为v2.9.0)</i></b>
<b><i>当前分支版本为重构后的版本重构前版本请在before分支中查看<br>(重构前版本不再更新,最新版本为v2.9.0)</i></b><br>
<b><i><a href="https://markusjoe.github.io/" target="_blank">点击跳转到帮助文档</a></i></b>
</div>
## 问题汇总

View File

@@ -95,6 +95,12 @@ client-settings:
# 填错默认 "zh_cn"
language: zh_cn
# [必填/只能一个] 日志等级
# 默认: DEBUG
# 可选: "DEBUG" "INFO" "WARNING" "ERROR" "CRITICAL"
level: DEBUG
# [标识/不填] 仅作用户读取标识
only-view-settings:
# 城市名

View File

@@ -15,6 +15,8 @@ from core.logger import Logger
from core.language import Language
from core.read_config import read_config
Logger.info('Be imported')
settings = read_config()
if not os.path.exists('./logs'):

View File

@@ -6,9 +6,12 @@
# @File Name: logger.py
from colorlog import ColoredFormatter
from core.read_config import read_config
import logging.handlers
import time
level = read_config()[2]['level']
date_format = '%H:%M:%S'
info_format_console = '%(log_color)s[%(asctime)s] |%(filename)s[ %(lineno)-3s] |%(levelname)-8s |%(message)s'
info_format_file = '[%(asctime)s] |%(filename)s[%(funcName)sline:%(lineno)d] |%(levelname)-8s |%(message)s'
@@ -25,7 +28,21 @@ formatter_file = logging.Formatter(fmt=info_format_file,
datefmt=date_format)
Logger = logging.getLogger('MainLogger')
match level:
case 'DEBUG':
Logger.setLevel(logging.DEBUG)
case 'INFO':
Logger.setLevel(logging.INFO)
case 'WARNING':
Logger.setLevel(logging.WARNING)
case 'ERROR':
Logger.setLevel(logging.ERROR)
case 'CRITICAL':
Logger.setLevel(logging.CRITICAL)
case _:
Logger.setLevel(logging.DEBUG)
ConsoleLogger = logging.StreamHandler() # 输出到终端
ConsoleLogger.setFormatter(formatter)
log_name = time.strftime('%Y-%m-%d#%H') # 一小时内使用的日志文件都是同一个

View File

@@ -7,4 +7,4 @@
from core.logger import Logger
Logger.info('lib was called')
Logger.info('Be imported')

View File

@@ -4,3 +4,7 @@
# @Development Tool: PyCharm
# @Create Time: 2021/11/7
# @File Name: __init__.py.py
from core.logger import Logger
Logger.info('Be imported')