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"