From 87d35c9c41702c150ad1e41074bb6883592b0659 Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Tue, 27 Sep 2022 22:44:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20poetry=20=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=94=A8=E4=BA=8E=E4=BE=9D=E8=B5=96=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E4=B8=BA=20log=20=E5=AE=9E=E7=8E=B0=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E5=90=91=E6=96=87=E4=BB=B6=E6=97=A5=E5=BF=97=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 10 +++++++++- define.py | 9 ++++++++- logger/log_appender.py | 12 +++++++++++- pyproject.toml | 16 ++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore index 9a64d12..2e5715c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,10 @@ -__run/ + +# project working dir +__run__/ + +# project IDE configuration +.vscode/* + +# python toolchain auto-generated **__pycache__ +poetry.lock diff --git a/define.py b/define.py index ded7e31..2344174 100644 --- a/define.py +++ b/define.py @@ -1,6 +1,13 @@ +import os + + class Coeur_Def : + '''Morny Coeur python 程序以及当前的版本的元信息''' - VERSION = "0.7.2.1-py0.1" + VERSION = "0.1+coeur0.7.2.1" CODE = "fuzhou" TIMETAG = "2209261500" + + def is_file_logging () -> bool : + return os.getenv ("MORNY_LOGGING_TO_FILE") == "true" \ No newline at end of file diff --git a/logger/log_appender.py b/logger/log_appender.py index d387a15..c359c00 100644 --- a/logger/log_appender.py +++ b/logger/log_appender.py @@ -1,9 +1,19 @@ from datetime import datetime import threading + +from define import Coeur_Def from .log import * +if Coeur_Def.is_file_logging() : + log_file_archive = open(f"./logs/{time.strftime('%Y-%m-%d-%H:%M:%S.log', time.localtime())}", "x") + log_file = open("./log__latest.log", "a") + def output (message:Log) : - print(format_message(message)) + echo = format_message(message) + print(echo) + if Coeur_Def.is_file_logging() : + log_file.write(echo+"\n") + log_file_archive.write(echo+"\n") def format_message (log:Log) -> str : diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a0b78bc --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,16 @@ +[tool.poetry] +name = "morny-coeur-python" +version = "0.1+coeur0.7.2.1" +description = "A Coeur-Morny-Cono rewrite by python3" +authors = ["Eyre_S "] +readme = "README.md" +packages = [{include = "morny_coeur_python"}] + +[tool.poetry.dependencies] +python = "^3.10" +python-telegram-bot = "^13.14" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api"