From 29fed96a3b838100996edb472cfd7cf7372faf58 Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Sun, 25 Sep 2022 21:59:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86=20morny=20java=20?= =?UTF-8?q?=E6=89=80=E4=BD=BF=E7=94=A8=E7=9A=84=20messiva=20=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=AE=B0=E5=BD=95=E5=99=A8=E7=9A=84=E7=AE=80=E5=8D=95?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E7=9A=84=20Log=20=E6=A8=A1=E5=9E=8B=E5=92=8C?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=8F=B0=E8=BE=93=E5=87=BA=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ logger/log.py | 26 ++++++++++++++++++++++++++ logger/log_appender.py | 18 ++++++++++++++++++ logger/logger.py | 0 morny/morny_coeur.py | 4 ++++ start.py | 0 6 files changed, 50 insertions(+) create mode 100644 .gitignore create mode 100644 logger/log.py create mode 100644 logger/log_appender.py create mode 100644 logger/logger.py create mode 100644 morny/morny_coeur.py create mode 100644 start.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a64d12 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__run/ +**__pycache__ diff --git a/logger/log.py b/logger/log.py new file mode 100644 index 0000000..19b968a --- /dev/null +++ b/logger/log.py @@ -0,0 +1,26 @@ +import time + +class LogLevel: + def __init__(self, level:float, name:str) : + self.level = level + self.name = name + # def level (self) -> float : return self.level + # def name (self) -> str : return self.name + +class LogLevels: + trace:LogLevel = LogLevel(-1, "TRAC") + debug:LogLevel = LogLevel(0.1, "DBUG") + info:LogLevel = LogLevel(0, "INFO") + warn:LogLevel = LogLevel(0.5, "WARN") + error:LogLevel = LogLevel(1, "ERRO") + fatal:LogLevel = LogLevel(10, "FTAL") + null:LogLevel = LogLevel(0, "NULL") + +class Log: + def __init__ (self, message:str, level:LogLevel) : + self.timestamp = time.time_ns() + self.level = level + self.message = message + # def timestamp (self) -> int : return self.timestamp + # def level (self) -> LogLevel : return self.level + # def message (self) -> str : return self.message diff --git a/logger/log_appender.py b/logger/log_appender.py new file mode 100644 index 0000000..a5a0da4 --- /dev/null +++ b/logger/log_appender.py @@ -0,0 +1,18 @@ +from datetime import datetime +import threading +from .log import * + +def format_message (log:Log) -> str : + + origins = log.message.split("\n") + + message = "" + message += f"[{datetime.fromtimestamp(log.timestamp/1000/1000/1000).strftime('%Y-%m-%d/%H:%M:%S:%f')}]" + \ + f"[{threading.current_thread().name }]" + promptNewLine = "'"*len(message) + message += f"[{log.level.name}]{origins[0]}" + for i in range(len(origins)-1) : + message += f"\n{promptNewLine}[{log.level.name}]{origins[i+1]}" + + return message + diff --git a/logger/logger.py b/logger/logger.py new file mode 100644 index 0000000..e69de29 diff --git a/morny/morny_coeur.py b/morny/morny_coeur.py new file mode 100644 index 0000000..c8de17f --- /dev/null +++ b/morny/morny_coeur.py @@ -0,0 +1,4 @@ +class MornyCoeur : + + + \ No newline at end of file diff --git a/start.py b/start.py new file mode 100644 index 0000000..e69de29