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] =?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;