From 986706f4977d70738cba10d63c31b77824a01d46 Mon Sep 17 00:00:00 2001 From: hinak0 <2782772457@qq.com> Date: Thu, 1 Sep 2022 20:32:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0bash=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=EF=BC=8C=E5=A2=9E=E5=8A=A0logging=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++++ config/logging.ini.example | 44 ++++++++++++++++++++++++++++++++++++++ start.bash | 6 ++++++ 3 files changed, 54 insertions(+) create mode 100644 config/logging.ini.example create mode 100755 start.bash diff --git a/.gitignore b/.gitignore index 00d6609..8dcf8bd 100644 --- a/.gitignore +++ b/.gitignore @@ -137,8 +137,12 @@ dmypy.json # 避免上传配置文件 config/*.json config/*.yaml +config/*.ini # push配置 config/push.ini .DS_Store yaml/ + +# 日志文件 +*.log diff --git a/config/logging.ini.example b/config/logging.ini.example new file mode 100644 index 0000000..1e769cf --- /dev/null +++ b/config/logging.ini.example @@ -0,0 +1,44 @@ +[loggers] +keys=root,AutoMihoyoBBS + +[handlers] +keys=fileHandler,consoleHandler + +[formatters] +keys=simpleFormatter + +; 缺少root logger会报错 +[logger_root] +level=DEBUG +handlers=fileHandler,consoleHandler + +[logger_AutoMihoyoBBS] +level=WARNING +handlers=fileHandler,consoleHandler + +; console +[handler_consoleHandler] +class=StreamHandler +args=(sys.stdout,) +level=DEBUG +formatter=simpleFormatter + +; file +[handler_fileHandler] +class=FileHandler +args=('logging.log', 'a') +level=DEBUG +formatter=simpleFormatter + +; 由于官方的SMTPHandler似乎不支持ssl邮箱,暂时不使用 +; Email +; [handler_SMTPHandler] +; class=handlers.SMTPHandler +; ; logging.handlers.SMTPHandler(mailhost,fromaddr,toaddrs,subject,credentials = None,secure = None,timeout = 1.0) +; args=() +; level=ERROR +; formatter=simpleFormatter + +[formatter_simpleFormatter] +format=%(asctime)s - %(name)s - %(levelname)s - %(message)s +datefmt=%Y-%m-%dT%H:%M:%S \ No newline at end of file diff --git a/start.bash b/start.bash new file mode 100755 index 0000000..96b0569 --- /dev/null +++ b/start.bash @@ -0,0 +1,6 @@ +#!/bin/bash +# 进入脚本所在目录 +cd $(cd `dirname $0`;pwd) +# 随机延时$RANDOM值为1~32767 +sleep $[$RANDOM%1200]; +python ./main.py; From 0f9e1fffdff3f04fa216950a59b05c40eb4ad832 Mon Sep 17 00:00:00 2001 From: hinak0 <2782772457@qq.com> Date: Thu, 1 Sep 2022 21:00:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?bugfix:=20=E4=BF=AE=E6=AD=A3=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=96=87=E4=BB=B6=E7=9A=84=E4=B8=80=E4=B8=AA=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/logging.ini.example | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/logging.ini.example b/config/logging.ini.example index 1e769cf..78e4c44 100644 --- a/config/logging.ini.example +++ b/config/logging.ini.example @@ -14,13 +14,14 @@ handlers=fileHandler,consoleHandler [logger_AutoMihoyoBBS] level=WARNING +qualname=fileHandler,consoleHandler handlers=fileHandler,consoleHandler ; console [handler_consoleHandler] class=StreamHandler args=(sys.stdout,) -level=DEBUG +level=INFO formatter=simpleFormatter ; file