Compare commits
No commits in common. "e5c87bf42e70b7e4246db4c2eceec13fb1a74063" and "df4105ec61be602fbd9fee8f1b6b72df65c9fca7" have entirely different histories.
e5c87bf42e
...
df4105ec61
15
.github/workflows/get_info.py
vendored
15
.github/workflows/get_info.py
vendored
@ -7,24 +7,15 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import rtoml
|
import rtoml
|
||||||
import io
|
|
||||||
|
|
||||||
|
|
||||||
sys.path.append(os.path.abspath(os.curdir))
|
sys.path.append(os.path.abspath(os.curdir))
|
||||||
|
|
||||||
is_github = "-github" in sys.argv
|
|
||||||
|
|
||||||
if is_github:
|
|
||||||
stdout = sys.stdout
|
|
||||||
sys.stdout = io.StringIO()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from Difficult_Rocket import DR_status
|
from Difficult_Rocket import DR_status
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if is_github:
|
args = ["-env", "-github-dev"]
|
||||||
sys.stdout = stdout
|
|
||||||
|
|
||||||
|
|
||||||
if sys.argv == [__file__]: # 没有输入参数,直接输出默认信息并输出
|
if sys.argv == [__file__]: # 没有输入参数,直接输出默认信息并输出
|
||||||
@ -37,6 +28,10 @@ if sys.argv == [__file__]: # 没有输入参数,直接输出默认信息并
|
|||||||
config_file["window"]["height"] = 768
|
config_file["window"]["height"] = 768
|
||||||
rtoml.dump(config_file, open("./config/main.toml", "w"))
|
rtoml.dump(config_file, open("./config/main.toml", "w"))
|
||||||
|
|
||||||
|
elif os.path.abspath(os.curdir) in sys.path and "-env" in sys.argv:
|
||||||
|
with open("./.github/workflows/env.ps1", encoding="utf-8", mode="w") as env_file:
|
||||||
|
print(f'$env:DR_version = "{DR_status.DR_version}"', file=env_file)
|
||||||
|
print(f'$env:Build_version = "{DR_status.Build_version}"', file=env_file)
|
||||||
elif os.path.abspath(os.curdir) in sys.path and "-github" in sys.argv:
|
elif os.path.abspath(os.curdir) in sys.path and "-github" in sys.argv:
|
||||||
print(f"DR_version={DR_status.DR_version}")
|
print(f"DR_version={DR_status.DR_version}")
|
||||||
print(f"Build_version={DR_status.Build_version}")
|
print(f"Build_version={DR_status.Build_version}")
|
||||||
|
@ -4,26 +4,28 @@
|
|||||||
# All rights reserved
|
# All rights reserved
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
|
|
||||||
|
import time
|
||||||
|
import logging.config
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from Difficult_Rocket.api.types import Options, Version
|
from Difficult_Rocket.api.types import Options, Version
|
||||||
|
|
||||||
sdk_version = Version("0.9.0.0-alpha.0") # SDK 版本
|
sdk_version = Version("0.8.7.3") # SDK 版本
|
||||||
build_version = Version("2.2.0.0") # 编译文件版本(与游戏本体无关)
|
build_version = Version("2.2.0.0") # 编译文件版本(与游戏本体无关)
|
||||||
api_version = Version("0.1.1.0") # API 版本
|
api_version = Version("0.1.1.0") # API 版本
|
||||||
__version__ = sdk_version
|
__version__ = sdk_version
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
# __init__
|
# __init__
|
||||||
"DR_status",
|
"DR_status",
|
||||||
# folder
|
# folder
|
||||||
"api",
|
"api",
|
||||||
"data",
|
|
||||||
"client",
|
"client",
|
||||||
|
"server",
|
||||||
"command",
|
"command",
|
||||||
"crash",
|
"crash",
|
||||||
"exception",
|
"exception",
|
||||||
"server",
|
|
||||||
"mod",
|
"mod",
|
||||||
"utils",
|
"utils",
|
||||||
# file
|
# file
|
||||||
@ -35,12 +37,12 @@ __all__ = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class _DRStatus(Options):
|
class _DR_status(Options):
|
||||||
"""
|
"""
|
||||||
DR 的特性开关 / 基本状态
|
DR 的特性开关 / 基本状态
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name = "DR Status"
|
name = "DR Option"
|
||||||
# run status
|
# run status
|
||||||
client_running: bool = False
|
client_running: bool = False
|
||||||
server_running: bool = False
|
server_running: bool = False
|
||||||
@ -51,6 +53,7 @@ class _DRStatus(Options):
|
|||||||
report_translate_not_found: bool = True
|
report_translate_not_found: bool = True
|
||||||
use_multiprocess: bool = False
|
use_multiprocess: bool = False
|
||||||
use_cProfile: bool = False
|
use_cProfile: bool = False
|
||||||
|
use_local_logging: bool = False
|
||||||
|
|
||||||
# tests
|
# tests
|
||||||
playing: bool = False
|
playing: bool = False
|
||||||
@ -73,52 +76,31 @@ class _DRStatus(Options):
|
|||||||
return round(12 * self.gui_scale)
|
return round(12 * self.gui_scale)
|
||||||
|
|
||||||
|
|
||||||
DR_status = _DRStatus()
|
DR_status = _DR_status()
|
||||||
|
|
||||||
|
|
||||||
def load_logger():
|
def load_logging():
|
||||||
log_config_path = Path("./config/lndl-logger.toml")
|
with open("./config/logger.toml") as f:
|
||||||
|
|
||||||
import rtoml
|
import rtoml
|
||||||
|
|
||||||
warn_config = False
|
|
||||||
if not log_config_path.is_file():
|
|
||||||
# 生成默认配置文件
|
|
||||||
from Difficult_Rocket.data import log_config
|
|
||||||
|
|
||||||
try:
|
|
||||||
log_config_path.write_text(log_config.default_config)
|
|
||||||
except (FileNotFoundError, OSError, PermissionError):
|
|
||||||
print("\033[31mFailed to write default log config file\033[0m")
|
|
||||||
warn_config = True
|
|
||||||
logger_config = rtoml.loads(log_config.default_config)
|
|
||||||
else:
|
|
||||||
# 读取配置文件
|
|
||||||
with open(log_config_path, encoding="utf-8") as f:
|
|
||||||
logger_config = rtoml.load(f)
|
logger_config = rtoml.load(f)
|
||||||
# 输入 lndl 进行配置
|
log_path = logger_config["handlers"]["file"]["filename"]
|
||||||
from lib_not_dr.loggers.config import read_config, get_logger
|
log_path = f"logs/{log_path.format(time.strftime('%Y-%m-%d %H-%M-%S', time.gmtime(time.time_ns() / 1000_000_000)))}"
|
||||||
|
if not Path("logs/").is_dir():
|
||||||
read_config(logger_config)
|
Path("logs/").mkdir()
|
||||||
logger = get_logger("main")
|
logger_config["handlers"]["file"]["filename"] = log_path
|
||||||
logger.info("Logger config loaded", tag="DR-init")
|
logging.config.dictConfig(logger_config)
|
||||||
logger.info(f"DR status:\n{DR_status.as_markdown()}", tag="DR-init")
|
|
||||||
if warn_config:
|
|
||||||
logger.warn("Failed to load log config file, use default config", tag="DR-init")
|
|
||||||
|
|
||||||
|
|
||||||
# 读取日志配置
|
load_logging()
|
||||||
# 也保证可以直接运行,不带日志 ( 因为有默认配置 )
|
|
||||||
load_logger()
|
|
||||||
|
|
||||||
if DR_status.playing:
|
if DR_status.playing:
|
||||||
from Difficult_Rocket.utils.thread import new_thread
|
from Difficult_Rocket.utils.thread import new_thread
|
||||||
|
|
||||||
|
|
||||||
def think_it(something):
|
def think_it(something):
|
||||||
return something
|
return something
|
||||||
|
|
||||||
|
|
||||||
@new_thread("think")
|
@new_thread("think")
|
||||||
def think(some_thing_to_think):
|
def think(some_thing_to_think):
|
||||||
gotcha = think_it(some_thing_to_think)
|
gotcha = think_it(some_thing_to_think)
|
||||||
|
@ -11,6 +11,7 @@ github: @shenjackyuanjie
|
|||||||
gitee: @shenjackyuanjie
|
gitee: @shenjackyuanjie
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"exception",
|
"exception",
|
||||||
# 错误类定义
|
# 错误类定义
|
||||||
|
@ -33,6 +33,7 @@ class BaseScreen(EventDispatcher, Options):
|
|||||||
self.window_pointer = main_window
|
self.window_pointer = main_window
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|
||||||
def on_command(self, command: CommandText, window: ClientWindow):
|
def on_command(self, command: CommandText, window: ClientWindow):
|
||||||
"""
|
"""
|
||||||
命令输入事件
|
命令输入事件
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
import inspect
|
import inspect
|
||||||
import functools
|
import functools
|
||||||
import traceback
|
import traceback
|
||||||
@ -42,9 +43,8 @@ from Difficult_Rocket.client.screen import DRDEBUGScreen
|
|||||||
from Difficult_Rocket.client.fps.fps_log import FpsLogger
|
from Difficult_Rocket.client.fps.fps_log import FpsLogger
|
||||||
from Difficult_Rocket.exception.language import LanguageNotFound
|
from Difficult_Rocket.exception.language import LanguageNotFound
|
||||||
|
|
||||||
from lib_not_dr import loggers
|
|
||||||
|
|
||||||
logger = loggers.config.get_logger("client")
|
logger = logging.getLogger("client")
|
||||||
|
|
||||||
|
|
||||||
class ClientOption(Options):
|
class ClientOption(Options):
|
||||||
@ -78,7 +78,7 @@ class Client:
|
|||||||
def __init__(self, game: "Game", net_mode="local"):
|
def __init__(self, game: "Game", net_mode="local"):
|
||||||
start_time = time.time_ns()
|
start_time = time.time_ns()
|
||||||
# logging
|
# logging
|
||||||
self.logger = loggers.get_logger("client")
|
self.logger = logging.getLogger("client")
|
||||||
self.logger.info(tr().client.setup.start())
|
self.logger.info(tr().client.setup.start())
|
||||||
# config
|
# config
|
||||||
self.config = ClientOption()
|
self.config = ClientOption()
|
||||||
@ -128,7 +128,7 @@ def pyglet_load_fonts_folder(folder) -> None:
|
|||||||
if not font_path.exists():
|
if not font_path.exists():
|
||||||
font_path.mkdir(parents=True)
|
font_path.mkdir(parents=True)
|
||||||
return None
|
return None
|
||||||
logger.info(tr().client.load.font.start().format(font_path), tag="font")
|
logger.info(tr().client.load.font.start().format(font_path))
|
||||||
start_time = time.time_ns()
|
start_time = time.time_ns()
|
||||||
for dir_path, dir_names, file_names in os.walk(font_path):
|
for dir_path, dir_names, file_names in os.walk(font_path):
|
||||||
dir_path = Path(dir_path)
|
dir_path = Path(dir_path)
|
||||||
@ -136,8 +136,7 @@ def pyglet_load_fonts_folder(folder) -> None:
|
|||||||
file_name = Path(file_name)
|
file_name = Path(file_name)
|
||||||
if file_name.suffix in (".ttf", ".otf"):
|
if file_name.suffix in (".ttf", ".otf"):
|
||||||
logger.debug(
|
logger.debug(
|
||||||
tr().client.load.font.file().format(str(dir_path / file_name)),
|
tr().client.load.font.file().format(str(dir_path / file_name))
|
||||||
tag="font",
|
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
pyglet.font.add_file(str(dir_path / file_name))
|
pyglet.font.add_file(str(dir_path / file_name))
|
||||||
@ -149,9 +148,7 @@ def pyglet_load_fonts_folder(folder) -> None:
|
|||||||
)
|
)
|
||||||
end_time = time.time_ns()
|
end_time = time.time_ns()
|
||||||
use_time = end_time - start_time
|
use_time = end_time - start_time
|
||||||
logger.info(
|
logger.info(tr().client.load.font.use_time().format(use_time / 1000000000))
|
||||||
tr().client.load.font.use_time().format(use_time / 1000000000), tag="font"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _call_back(call_back: Callable) -> Callable:
|
def _call_back(call_back: Callable) -> Callable:
|
||||||
@ -243,7 +240,7 @@ class ClientWindow(Window):
|
|||||||
start_time = time.time_ns()
|
start_time = time.time_ns()
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
# logging
|
# logging
|
||||||
self.logger = loggers.get_logger("client")
|
self.logger = logging.getLogger("client")
|
||||||
self.logger.info(tr().window.setup.start())
|
self.logger.info(tr().window.setup.start())
|
||||||
# value
|
# value
|
||||||
self.game = game
|
self.game = game
|
||||||
@ -310,13 +307,10 @@ class ClientWindow(Window):
|
|||||||
# TODO: wait for pyglet 2.1
|
# TODO: wait for pyglet 2.1
|
||||||
pyglet.app.run(float(self.SPF))
|
pyglet.app.run(float(self.SPF))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
self.logger.warn(
|
self.logger.warning("==========client stop. KeyboardInterrupt info==========")
|
||||||
"==========client stop. KeyboardInterrupt info==========", tag="starter"
|
|
||||||
)
|
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
self.logger.warn(
|
self.logger.warning(
|
||||||
"==========client stop. KeyboardInterrupt info end==========",
|
"==========client stop. KeyboardInterrupt info end=========="
|
||||||
tag="starter",
|
|
||||||
)
|
)
|
||||||
self.dispatch_event("on_close", "input")
|
self.dispatch_event("on_close", "input")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -36,9 +36,9 @@ class FpsLogger:
|
|||||||
else:
|
else:
|
||||||
self.fps_list.append(float(1 / tick))
|
self.fps_list.append(float(1 / tick))
|
||||||
if len(self.fps_list) > self.count:
|
if len(self.fps_list) > self.count:
|
||||||
self.fps_list = self.fps_list[-self.count + 1:] # 整个列表往前挪一位
|
self.fps_list = self.fps_list[-self.count + 1 :] # 整个列表往前挪一位
|
||||||
if len(self.get_fps_list) > self.count:
|
if len(self.get_fps_list) > self.count:
|
||||||
self.get_fps_list = self.get_fps_list[-self.count + 1:] # 整个列表往前挪一位
|
self.get_fps_list = self.get_fps_list[-self.count + 1 :] # 整个列表往前挪一位
|
||||||
try:
|
try:
|
||||||
self._fps = statistics.geometric_mean(
|
self._fps = statistics.geometric_mean(
|
||||||
self.fps_list[-100:]
|
self.fps_list[-100:]
|
||||||
|
@ -50,9 +50,9 @@ class CommandText:
|
|||||||
if find != -1:
|
if find != -1:
|
||||||
if not len(text) == len(self.text):
|
if not len(text) == len(self.text):
|
||||||
self.text = (
|
self.text = (
|
||||||
self.text[find + len(text):]
|
self.text[find + len(text) :]
|
||||||
if not self.text[find + len(text)] == " "
|
if not self.text[find + len(text)] == " "
|
||||||
else self.text[find + len(text) + 1:]
|
else self.text[find + len(text) + 1 :]
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -68,7 +68,7 @@ class CommandText:
|
|||||||
# 20230122 我现在也不知道为啥这么写了
|
# 20230122 我现在也不知道为啥这么写了
|
||||||
# 果然使用正则表达式就是让一个问题变成两个问题
|
# 果然使用正则表达式就是让一个问题变成两个问题
|
||||||
except IndexError:
|
except IndexError:
|
||||||
self.text = self.text[finding.span()[1] + 1:]
|
self.text = self.text[finding.span()[1] + 1 :]
|
||||||
return True
|
return True
|
||||||
if next_find == " ":
|
if next_find == " ":
|
||||||
return True
|
return True
|
||||||
|
@ -1,86 +0,0 @@
|
|||||||
# -------------------------------
|
|
||||||
# Difficult Rocket
|
|
||||||
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
|
|
||||||
# All rights reserved
|
|
||||||
# -------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
default_config = """config_version = 1
|
|
||||||
|
|
||||||
[Logger]
|
|
||||||
|
|
||||||
[Logger.client]
|
|
||||||
# 日志名称
|
|
||||||
logger_name = "client"
|
|
||||||
level_name = "debug"
|
|
||||||
# or 'DEBUG'
|
|
||||||
# or level = 10
|
|
||||||
outputs = ["std_out", "file_out"]
|
|
||||||
|
|
||||||
[Logger.server]
|
|
||||||
# 日志名称
|
|
||||||
logger_name = "server"
|
|
||||||
level_name = "debug"
|
|
||||||
# or 'DEBUG'
|
|
||||||
# or level = 10
|
|
||||||
outputs = ["std_out", "file_out"]
|
|
||||||
|
|
||||||
[Logger.main]
|
|
||||||
# 日志名称
|
|
||||||
logger_name = "main"
|
|
||||||
level_name = "debug"
|
|
||||||
# or 'DEBUG'
|
|
||||||
# or level = 10
|
|
||||||
outputs = ["std_out", "file_out"]
|
|
||||||
|
|
||||||
[Formatter]
|
|
||||||
|
|
||||||
[Formatter.main_formatter]
|
|
||||||
# 格式化器名称
|
|
||||||
class = "MainFormatter"
|
|
||||||
# 格式化器参数
|
|
||||||
time_format = "%Y-%m-%d %H:%M:%S"
|
|
||||||
msec_time_format = "{}-{:03d}"
|
|
||||||
use_absolute_path = false
|
|
||||||
|
|
||||||
[Formatter.std_formatter]
|
|
||||||
class = "StdFormatter"
|
|
||||||
sub_formatter = ["main_formatter"]
|
|
||||||
default_template = "[${log_time}][${level}]|${logger_name}:${logger_tag}|${messages}"
|
|
||||||
|
|
||||||
[Outstream]
|
|
||||||
|
|
||||||
[Outstream.std_out]
|
|
||||||
# 输出流名称
|
|
||||||
class = "StdioOutputStream"
|
|
||||||
# 输出流参数
|
|
||||||
formatter = "std_formatter"
|
|
||||||
use_stderr = false
|
|
||||||
# or true
|
|
||||||
level_name = "debug"
|
|
||||||
# or 'DEBUG'
|
|
||||||
# or level = 10
|
|
||||||
|
|
||||||
[Outstream.file_out]
|
|
||||||
class = "FileCacheOutputStream"
|
|
||||||
|
|
||||||
level = 10
|
|
||||||
# or level_name = 'DEBUG'
|
|
||||||
# or level_name = 'debug'
|
|
||||||
formatter = "std_formatter"
|
|
||||||
flush_count_limit = 10
|
|
||||||
# 5 条日志刷新一次
|
|
||||||
flush_time_limit = 5
|
|
||||||
# 5 秒刷新一次
|
|
||||||
# or flush_time_limit = 0.5
|
|
||||||
file_path = "./logs"
|
|
||||||
file_name = "dr-{time}.log"
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
# 整的跟 export 一样
|
|
||||||
# fmt: off
|
|
||||||
__all__ = [
|
|
||||||
"default_config"
|
|
||||||
]
|
|
||||||
# fmt: on
|
|
@ -23,6 +23,7 @@ class BaseTheme(dict):
|
|||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
|
||||||
def init(self, batch: Batch, group: Group, **kwargs) -> None:
|
def init(self, batch: Batch, group: Group, **kwargs) -> None:
|
||||||
"""
|
"""
|
||||||
Init theme
|
Init theme
|
||||||
|
@ -11,17 +11,27 @@ github: @shenjackyuanjie
|
|||||||
gitee: @shenjackyuanjie
|
gitee: @shenjackyuanjie
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# import time
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# import traceback
|
||||||
|
import logging.config
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
||||||
|
# from io import StringIO
|
||||||
|
# from pathlib import Path
|
||||||
from typing import List, Optional, Dict
|
from typing import List, Optional, Dict
|
||||||
|
|
||||||
|
# from Difficult_Rocket.utils import tools
|
||||||
from Difficult_Rocket.api.types import Options
|
from Difficult_Rocket.api.types import Options
|
||||||
|
|
||||||
|
# from Difficult_Rocket.utils.translate import tr
|
||||||
|
# from Difficult_Rocket.runtime import DR_runtime
|
||||||
from Difficult_Rocket.mod.loader import ModManager
|
from Difficult_Rocket.mod.loader import ModManager
|
||||||
from Difficult_Rocket.utils.thread import new_thread
|
from Difficult_Rocket.utils.thread import new_thread
|
||||||
from Difficult_Rocket import client, server, DR_status
|
|
||||||
|
|
||||||
from lib_not_dr.loggers import config
|
# from Difficult_Rocket.crash import write_info_to_cache
|
||||||
from lib_not_dr.loggers.logger import Logger
|
from Difficult_Rocket import client, server, DR_status
|
||||||
|
|
||||||
|
|
||||||
class Console(Options):
|
class Console(Options):
|
||||||
@ -65,7 +75,7 @@ class Game(Options):
|
|||||||
console_class: Console = Console
|
console_class: Console = Console
|
||||||
|
|
||||||
main_config: Dict
|
main_config: Dict
|
||||||
logger: Logger
|
logger: logging.Logger
|
||||||
|
|
||||||
mod_manager: ModManager
|
mod_manager: ModManager
|
||||||
|
|
||||||
@ -74,6 +84,9 @@ class Game(Options):
|
|||||||
|
|
||||||
def init_mods(self) -> None:
|
def init_mods(self) -> None:
|
||||||
"""验证/加载 mod"""
|
"""验证/加载 mod"""
|
||||||
|
from Difficult_Rocket.mod import loader as mod_loader
|
||||||
|
|
||||||
|
mod_loader.logger = logging.getLogger("mod_manager")
|
||||||
self.mod_manager = ModManager()
|
self.mod_manager = ModManager()
|
||||||
mod_class = self.mod_manager.load_mods()
|
mod_class = self.mod_manager.load_mods()
|
||||||
self.mod_manager.init_mods(mod_class)
|
self.mod_manager.init_mods(mod_class)
|
||||||
@ -107,7 +120,7 @@ class Game(Options):
|
|||||||
self.server = server.Server(net_mode="local")
|
self.server = server.Server(net_mode="local")
|
||||||
|
|
||||||
def init(self, **kwargs) -> bool:
|
def init(self, **kwargs) -> bool:
|
||||||
self.logger = config.get_logger("main")
|
self.logger = logging.getLogger("main")
|
||||||
self.load_file()
|
self.load_file()
|
||||||
self.setup()
|
self.setup()
|
||||||
self.log_env()
|
self.log_env()
|
||||||
|
@ -3,3 +3,4 @@
|
|||||||
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
|
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
|
||||||
# All rights reserved
|
# All rights reserved
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
import importlib
|
import importlib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -15,11 +16,9 @@ from Difficult_Rocket.mod.api import ModInfo
|
|||||||
from Difficult_Rocket.utils.translate import tr
|
from Difficult_Rocket.utils.translate import tr
|
||||||
from Difficult_Rocket.api.types import Options
|
from Difficult_Rocket.api.types import Options
|
||||||
|
|
||||||
from lib_not_dr.loggers import config
|
|
||||||
|
|
||||||
Game = TypeVar("Game")
|
Game = TypeVar("Game")
|
||||||
|
|
||||||
logger = config.get_logger_from_old("mod_manager", "client")
|
logger = logging.getLogger("mod_manager")
|
||||||
ONE_FILE_SUFFIX = (".py", ".pyc", ".pyd")
|
ONE_FILE_SUFFIX = (".py", ".pyc", ".pyd")
|
||||||
PACKAGE_SUFFIX = (".pyz", ".zip", ".dr_mod")
|
PACKAGE_SUFFIX = (".pyz", ".zip", ".dr_mod")
|
||||||
|
|
||||||
@ -74,14 +73,14 @@ class ModManager(Options):
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if not mod_path.exists():
|
if not mod_path.exists():
|
||||||
logger.error(tr().mod.load.faild.not_exist().format(mod_path), tag="load")
|
logger.error(tr().mod.load.faild.not_exist().format(mod_path))
|
||||||
return None
|
return None
|
||||||
_add_path_to_sys([mod_path.parent])
|
_add_path_to_sys([mod_path.parent])
|
||||||
try:
|
try:
|
||||||
if mod_path.name == "__pycache__":
|
if mod_path.name == "__pycache__":
|
||||||
# 忽略 __pycache__ 文件夹 (Python 编译文件)
|
# 忽略 __pycache__ 文件夹 (Python 编译文件)
|
||||||
return None
|
return None
|
||||||
logger.info(tr().mod.load.loading().format(mod_path), tag="load")
|
logger.info(tr().mod.load.loading().format(mod_path))
|
||||||
if (
|
if (
|
||||||
mod_path.is_dir()
|
mod_path.is_dir()
|
||||||
or mod_path.suffix in PACKAGE_SUFFIX
|
or mod_path.suffix in PACKAGE_SUFFIX
|
||||||
@ -92,18 +91,15 @@ class ModManager(Options):
|
|||||||
if not hasattr(loading_mod, "mod_class") or not issubclass(
|
if not hasattr(loading_mod, "mod_class") or not issubclass(
|
||||||
loading_mod.mod_class, ModInfo
|
loading_mod.mod_class, ModInfo
|
||||||
):
|
):
|
||||||
logger.warn(
|
logger.warning(tr().mod.load.faild.no_mod_class().format(mod_path))
|
||||||
tr().mod.load.faild.no_mod_class().format(mod_path), tag="load"
|
|
||||||
)
|
|
||||||
return None
|
return None
|
||||||
mod_class: type(ModInfo) = loading_mod.mod_class # 获取 mod 类
|
mod_class: type(ModInfo) = loading_mod.mod_class # 获取 mod 类
|
||||||
if mod_class.mod_id not in self.find_mod_paths:
|
if mod_class.mod_id not in self.find_mod_paths:
|
||||||
self.find_mod_paths[mod_class.mod_id] = mod_path
|
self.find_mod_paths[mod_class.mod_id] = mod_path
|
||||||
return mod_class
|
return mod_class
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logger.warn(
|
logger.warning(
|
||||||
tr().mod.load.faild.error().format(mod_path, traceback.format_exc()),
|
tr().mod.load.faild.error().format(mod_path, traceback.format_exc())
|
||||||
tag="load",
|
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -134,9 +130,7 @@ class ModManager(Options):
|
|||||||
):
|
):
|
||||||
# 文件夹 mod
|
# 文件夹 mod
|
||||||
mods_path.append(mod)
|
mods_path.append(mod)
|
||||||
logger.info(
|
logger.info(tr().mod.finded().format(len(mods_path), time.time() - start_time))
|
||||||
tr().mod.finded().format(len(mods_path), time.time() - start_time), tag="find"
|
|
||||||
)
|
|
||||||
return mods_path
|
return mods_path
|
||||||
|
|
||||||
def load_mods(
|
def load_mods(
|
||||||
@ -154,7 +148,7 @@ class ModManager(Options):
|
|||||||
_add_path_to_sys(find_path)
|
_add_path_to_sys(find_path)
|
||||||
mods = []
|
mods = []
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
logger.info(tr().mod.load.start().format(find_path), tag="load")
|
logger.info(tr().mod.load.start().format(find_path))
|
||||||
for path in find_path:
|
for path in find_path:
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
path.mkdir(parents=True)
|
path.mkdir(parents=True)
|
||||||
@ -166,7 +160,7 @@ class ModManager(Options):
|
|||||||
for path in extra_mod_path:
|
for path in extra_mod_path:
|
||||||
if (cache := self.load_mod(path)) is not None:
|
if (cache := self.load_mod(path)) is not None:
|
||||||
mods.append(cache)
|
mods.append(cache)
|
||||||
logger.info(tr().mod.load.use_time().format(time.time() - start_time), tag="load")
|
logger.info(tr().mod.load.use_time().format(time.time() - start_time))
|
||||||
return mods
|
return mods
|
||||||
|
|
||||||
def init_mods(self, mods: List[type(ModInfo)]):
|
def init_mods(self, mods: List[type(ModInfo)]):
|
||||||
@ -180,16 +174,13 @@ class ModManager(Options):
|
|||||||
try:
|
try:
|
||||||
init_mod = mod_class()
|
init_mod = mod_class()
|
||||||
self.loaded_mod_modules[init_mod.mod_id] = init_mod
|
self.loaded_mod_modules[init_mod.mod_id] = init_mod
|
||||||
logger.info(
|
logger.info(tr().mod.init.success().format(init_mod, init_mod.version))
|
||||||
tr().mod.init.success().format(init_mod, init_mod.version), tag="init"
|
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(
|
logger.error(
|
||||||
tr().mod.init.faild().format(mod_class, e, traceback.format_exc()),
|
tr().mod.init.faild().format(mod_class, e, traceback.format_exc())
|
||||||
tag="init",
|
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
logger.info(tr().mod.init.use_time().format(time.time() - start_time), tag="init")
|
logger.info(tr().mod.init.use_time().format(time.time() - start_time))
|
||||||
|
|
||||||
def unload_mod(self, mod_id: str, game: Game) -> Optional[ModInfo]:
|
def unload_mod(self, mod_id: str, game: Game) -> Optional[ModInfo]:
|
||||||
"""
|
"""
|
||||||
@ -202,17 +193,16 @@ class ModManager(Options):
|
|||||||
not (mod_class := self.loaded_mod_modules.get(mod_id))
|
not (mod_class := self.loaded_mod_modules.get(mod_id))
|
||||||
and (mod_class := self.get_mod_module(mod_id)) is None
|
and (mod_class := self.get_mod_module(mod_id)) is None
|
||||||
):
|
):
|
||||||
logger.warn(tr().mod.unload.faild.not_find().format(mod_id), tag="unload")
|
logger.warning(tr().mod.unload.faild.not_find().format(mod_id))
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
mod_class.on_unload(game=game)
|
mod_class.on_unload(game=game)
|
||||||
self.loaded_mod_modules.pop(mod_class.mod_id)
|
self.loaded_mod_modules.pop(mod_class.mod_id)
|
||||||
logger.info(tr().mod.unload.success().format(mod_id), tag="unload")
|
logger.info(tr().mod.unload.success().format(mod_id))
|
||||||
return mod_class
|
return mod_class
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(
|
logger.error(
|
||||||
tr().mod.unload.faild.error().format(mod_id, e, traceback.format_exc()),
|
tr().mod.unload.faild.error().format(mod_id, e, traceback.format_exc())
|
||||||
tag="unload",
|
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -228,9 +218,7 @@ class ModManager(Options):
|
|||||||
return
|
return
|
||||||
mod_class: Optional[ModInfo] = None
|
mod_class: Optional[ModInfo] = None
|
||||||
if unload.mod_id not in self.find_mod_paths:
|
if unload.mod_id not in self.find_mod_paths:
|
||||||
logger.warn(
|
logger.warning(tr().mod.reload.faild.not_find().format(unload.mod_id))
|
||||||
tr().mod.reload.faild.not_find().format(unload.mod_id), tag="reload"
|
|
||||||
)
|
|
||||||
paths = self.find_mods_in_path()
|
paths = self.find_mods_in_path()
|
||||||
for path in paths:
|
for path in paths:
|
||||||
mod_class = self.load_mod(path)
|
mod_class = self.load_mod(path)
|
||||||
@ -243,4 +231,4 @@ class ModManager(Options):
|
|||||||
self.init_mods([mod_class])
|
self.init_mods([mod_class])
|
||||||
if mod_id in self.loaded_mod_modules and mod_class is not None:
|
if mod_id in self.loaded_mod_modules and mod_class is not None:
|
||||||
self.loaded_mod_modules[mod_id].on_load(game=game, old_self=mod_class)
|
self.loaded_mod_modules[mod_id].on_load(game=game, old_self=mod_class)
|
||||||
logger.info(tr().mod.reload.success().format(mod_id), tag="reload")
|
logger.info(tr().mod.reload.success().format(mod_id))
|
||||||
|
@ -14,6 +14,7 @@ from typing import Optional, List, Tuple
|
|||||||
|
|
||||||
from Difficult_Rocket.api.types import Options, Version
|
from Difficult_Rocket.api.types import Options, Version
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["DR_runtime"]
|
__all__ = ["DR_runtime"]
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,12 +13,13 @@ gitee: @shenjackyuanjie
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
# import multiprocessing
|
# import multiprocessing
|
||||||
|
|
||||||
from Difficult_Rocket.utils import tools
|
from Difficult_Rocket.utils import tools
|
||||||
from Difficult_Rocket.utils.translate import tr
|
from Difficult_Rocket.utils.translate import tr
|
||||||
|
# from Difficult_Rocket.api.delivery import Delivery
|
||||||
from lib_not_dr import loggers
|
# from Difficult_Rocket.utils.new_thread import new_thread
|
||||||
|
|
||||||
|
|
||||||
# TODO 改变服务端启动逻辑 0.6.0(划掉 0.8.0)会写完的(
|
# TODO 改变服务端启动逻辑 0.6.0(划掉 0.8.0)会写完的(
|
||||||
@ -28,7 +29,7 @@ class Server:
|
|||||||
def __init__(self, net_mode="local"):
|
def __init__(self, net_mode="local"):
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
# logging
|
# logging
|
||||||
self.logger = loggers.config.get_logger("server")
|
self.logger = logging.getLogger("server")
|
||||||
self.logger.info(tr().server.setup.start())
|
self.logger.info(tr().server.setup.start())
|
||||||
# value
|
# value
|
||||||
self.process_id = os.getpid()
|
self.process_id = os.getpid()
|
||||||
|
@ -17,6 +17,7 @@ import time
|
|||||||
import math
|
import math
|
||||||
import json
|
import json
|
||||||
import rtoml
|
import rtoml
|
||||||
|
import logging
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -26,10 +27,8 @@ from defusedxml.ElementTree import parse
|
|||||||
|
|
||||||
from Difficult_Rocket.exception.unsupport import NoMoreJson5
|
from Difficult_Rocket.exception.unsupport import NoMoreJson5
|
||||||
|
|
||||||
from lib_not_dr import loggers
|
|
||||||
|
|
||||||
# logger
|
# logger
|
||||||
tools_logger = loggers.config.get_logger("tools")
|
tools_logger = logging.getLogger("tools")
|
||||||
"""
|
"""
|
||||||
file config
|
file config
|
||||||
"""
|
"""
|
||||||
@ -49,7 +48,7 @@ def load_file(
|
|||||||
) -> Union[dict, ElementTree.ElementTree]:
|
) -> Union[dict, ElementTree.ElementTree]:
|
||||||
if isinstance(file_name, Path):
|
if isinstance(file_name, Path):
|
||||||
file_name = str(file_name)
|
file_name = str(file_name)
|
||||||
f_type = file_name[file_name.rfind(".") + 1:] # 从最后一个.到末尾 (截取文件格式)
|
f_type = file_name[file_name.rfind(".") + 1 :] # 从最后一个.到末尾 (截取文件格式)
|
||||||
get_file = NotImplementedError("解析失败,请检查文件类型/文件内容/文件是否存在!")
|
get_file = NotImplementedError("解析失败,请检查文件类型/文件内容/文件是否存在!")
|
||||||
try:
|
try:
|
||||||
if f_type == "xml":
|
if f_type == "xml":
|
||||||
@ -96,7 +95,7 @@ def load_file(
|
|||||||
|
|
||||||
|
|
||||||
def save_dict_file(file_name: str, data: dict, encoding: str = "utf-8") -> bool:
|
def save_dict_file(file_name: str, data: dict, encoding: str = "utf-8") -> bool:
|
||||||
f_type = file_name[file_name.rfind(".") + 1:] # 从最后一个.到末尾 (截取文件格式)
|
f_type = file_name[file_name.rfind(".") + 1 :] # 从最后一个.到末尾 (截取文件格式)
|
||||||
try:
|
try:
|
||||||
if (f_type == "config") or (f_type == "conf") or (f_type == "ini"):
|
if (f_type == "config") or (f_type == "conf") or (f_type == "ini"):
|
||||||
return False
|
return False
|
||||||
@ -202,6 +201,36 @@ def format_bool(thing) -> bool:
|
|||||||
raise TypeError("Need a 'like bool' not a {}".format(thing))
|
raise TypeError("Need a 'like bool' not a {}".format(thing))
|
||||||
|
|
||||||
|
|
||||||
|
level_ = [
|
||||||
|
"DEBUG",
|
||||||
|
"INFO",
|
||||||
|
"WARNING",
|
||||||
|
"ERROR",
|
||||||
|
"CRITICAL",
|
||||||
|
logging.DEBUG,
|
||||||
|
logging.INFO,
|
||||||
|
logging.WARNING,
|
||||||
|
logging.ERROR,
|
||||||
|
logging.CRITICAL,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def log_level(level):
|
||||||
|
if level in level_:
|
||||||
|
if (level == "DEBUG") or (level == logging.DEBUG):
|
||||||
|
return logging.DEBUG
|
||||||
|
if (level == "INFO") or (level == logging.INFO):
|
||||||
|
return logging.INFO
|
||||||
|
if (level == "WARNING") or (level == logging.WARNING):
|
||||||
|
return logging.WARNING
|
||||||
|
if (level == "ERROR") or (level == logging.ERROR):
|
||||||
|
return logging.ERROR
|
||||||
|
if (level == "CRITICAL") or (level == logging.CRITICAL):
|
||||||
|
return logging.CRITICAL
|
||||||
|
else:
|
||||||
|
raise ValueError("Need a like logging.level thing not anything else")
|
||||||
|
|
||||||
|
|
||||||
# linear_algebra
|
# linear_algebra
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,25 +34,18 @@ config_version = 1
|
|||||||
# 格式化器参数
|
# 格式化器参数
|
||||||
time_format = "%Y-%m-%d %H:%M:%S"
|
time_format = "%Y-%m-%d %H:%M:%S"
|
||||||
msec_time_format = "{}-{:03d}"
|
msec_time_format = "{}-{:03d}"
|
||||||
use_absolute_path = false
|
use_absolut_path = false
|
||||||
|
|
||||||
[Formatter.std_formatter]
|
[Formatter.std_formatter]
|
||||||
class = "StdFormatter"
|
formatter_class = "StdFormatter"
|
||||||
enable_color = true
|
|
||||||
sub_formatter = ["main_formatter"]
|
sub_formatter = ["main_formatter"]
|
||||||
default_template = "[${log_time}][${level}]|${logger_name}:${logger_tag}|${messages}"
|
default_template = "[{log_time}][{level}]|{logger_name}:{logger_tag}|{messages}"
|
||||||
|
|
||||||
[Formatter.file_std_formatter]
|
|
||||||
class = "StdFormatter"
|
|
||||||
enable_color = false
|
|
||||||
sub_formatter = ["main_formatter"]
|
|
||||||
default_template = "[${log_time}][${level}]|${logger_name}:${logger_tag}|${messages}"
|
|
||||||
|
|
||||||
[Outstream]
|
[Outstream]
|
||||||
|
|
||||||
[Outstream.std_out]
|
[Outstream.std_out]
|
||||||
# 输出流名称
|
# 输出流名称
|
||||||
class = "StdioOutputStream"
|
class = "StdOutputStream"
|
||||||
# 输出流参数
|
# 输出流参数
|
||||||
formatter = "std_formatter"
|
formatter = "std_formatter"
|
||||||
use_stderr = false
|
use_stderr = false
|
||||||
@ -67,11 +60,11 @@ config_version = 1
|
|||||||
level = 10
|
level = 10
|
||||||
# or level_name = 'DEBUG'
|
# or level_name = 'DEBUG'
|
||||||
# or level_name = 'debug'
|
# or level_name = 'debug'
|
||||||
formatter = "file_std_formatter"
|
formatter = "std_formatter"
|
||||||
flush_count_limit = 10
|
flush_count_limit = 10
|
||||||
# 5 条日志刷新一次
|
# 5 条日志刷新一次
|
||||||
flush_time_limit = 5
|
flush_time_limit = 5
|
||||||
# 5 秒刷新一次
|
# 5 秒刷新一次
|
||||||
# or flush_time_limit = 0.5
|
# or flush_time_limit = 0.5
|
||||||
file_path = "./logs"
|
file_path = "./logs"
|
||||||
file_name = "dr-{time}.log"
|
file_name = "%s-dr.log"
|
||||||
|
123
config/local_logger.toml
Normal file
123
config/local_logger.toml
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
logger_version = '1.0.0'
|
||||||
|
|
||||||
|
[Loggers]
|
||||||
|
|
||||||
|
[Loggers.root]
|
||||||
|
level = 'DEBUG'
|
||||||
|
color = 'main_color'
|
||||||
|
file = 'main_log_file'
|
||||||
|
handlers = ['main_std_handler']
|
||||||
|
|
||||||
|
[Loggers.client]
|
||||||
|
level = 'TRACE'
|
||||||
|
color = 'main_color'
|
||||||
|
file = 'main_log_file'
|
||||||
|
handlers = ['main_std_handler']
|
||||||
|
|
||||||
|
[Loggers.server]
|
||||||
|
level = 'TRACE'
|
||||||
|
color = 'DiGua_color'
|
||||||
|
file = 'main_log_file'
|
||||||
|
handlers = ['main_std_handler']
|
||||||
|
|
||||||
|
[Files]
|
||||||
|
|
||||||
|
[Files.main_log_file]
|
||||||
|
name = './logs/{long_time}_logs.md'
|
||||||
|
level = 'TRACE'
|
||||||
|
cache_len = 20
|
||||||
|
cache_time = 1
|
||||||
|
mode = 'a'
|
||||||
|
encoding = 'utf-8'
|
||||||
|
|
||||||
|
[Handler]
|
||||||
|
|
||||||
|
[Handler.main_std_handler]
|
||||||
|
class = 'str handler'
|
||||||
|
format = 'format.main_format'
|
||||||
|
|
||||||
|
[Handler.main_file_hander]
|
||||||
|
class = 'cached file handler'
|
||||||
|
format = 'format.main_format'
|
||||||
|
|
||||||
|
[Formatter]
|
||||||
|
|
||||||
|
main_format = '[{long_time}] [{logger_name}] {level} | {file_name}:{code_line} | {marker} | {message}'
|
||||||
|
file_name = 'no frame'
|
||||||
|
code_line = 'no frame'
|
||||||
|
short_time = '%Y-%m-%d %H-%M-%S'
|
||||||
|
long_time = '%Y-%m-%d %H-%M-%S:%%S'
|
||||||
|
|
||||||
|
[Colors]
|
||||||
|
|
||||||
|
[Colors.main_color]
|
||||||
|
# 翻了三个月的颜色啊
|
||||||
|
long_time = '\u001b[38;2;201;222;56m'
|
||||||
|
short_time = '\u001b[38;2;201;222;56m'
|
||||||
|
code_line = '\u001b[38;2;0;255;180m'
|
||||||
|
file_name = '\u001b[38;2;0;255;180m'
|
||||||
|
info = '\u001b[0m'
|
||||||
|
message = '\u001b[0m'
|
||||||
|
logger = '\u001b[0m'
|
||||||
|
marker = '\u001b[0m'
|
||||||
|
# level colors
|
||||||
|
TRACE.info = '\u001b[38;2;138;173;244m'
|
||||||
|
FINE.info = '\u001b[35;48;2;44;44;54m'
|
||||||
|
DEBUG.info = '\u001b[38;2;133;138;149m'
|
||||||
|
INFO.info = '\u001b[0m'
|
||||||
|
WARNING.info = '\u001b[33m'
|
||||||
|
ERROR.info = '\u001b[31m'
|
||||||
|
FATAL.info = '\u001b[38;2;255;255;0;48;2;120;10;10m'
|
||||||
|
FATAL.logger = '\u001b[38;2;245;189;230m'
|
||||||
|
|
||||||
|
[Colors.fancy_main_color]
|
||||||
|
long_time = '\u001b[38;2;201;222;56m'
|
||||||
|
short_time = '\u001b[38;2;201;222;56m'
|
||||||
|
file_name = '\u001b[38;2;0;255;180m'
|
||||||
|
code_line = '\u001b[38;2;0;255;180m'
|
||||||
|
info = '\u001b[0m'
|
||||||
|
message = '\u001b[0m'
|
||||||
|
logger = '\u001b[0m'
|
||||||
|
marker = '\u001b[0m'
|
||||||
|
# level colors
|
||||||
|
TRACE.info = '\u001b[38;2;138;173;244m'
|
||||||
|
TRACE.message = '\u001b[38;2;138;173;244m'
|
||||||
|
FINE.info = '\u001b[35;48;2;44;44;54m'
|
||||||
|
FINE.message = '\u001b[35m'
|
||||||
|
DEBUG.info = '\u001b[38;2;133;138;149m'
|
||||||
|
DEBUG.message = '\u001b[38;2;133;138;149m'
|
||||||
|
INFO.info = '\u001b[0m'
|
||||||
|
INFO.message = '\u001b[0m'
|
||||||
|
WARNING.info = '\u001b[33m'
|
||||||
|
WARNING.message = '\u001b[33m'
|
||||||
|
ERROR.info = '\u001b[31m'
|
||||||
|
ERROR.message = '\u001b[31m'
|
||||||
|
FATAL.info = '\u001b[38;2;255;255;0;48;2;120;10;10m'
|
||||||
|
FATAL.message = '\u001b[38;2;255;255;0;48;2;120;10;10m'
|
||||||
|
FATAL.logger = '\u001b[38;2;245;189;230m'
|
||||||
|
|
||||||
|
[Colors.DiGua_color]
|
||||||
|
# catppuccin Macchiato
|
||||||
|
long_time = '\u001b[38;2;202;211;245m'
|
||||||
|
short_time = '\u001b[38;2;202;211;245m'
|
||||||
|
file_name = '\u001b[38;2;139;213;202m'
|
||||||
|
code_line = '\u001b[38;2;166;218;149m'
|
||||||
|
info = '\u001b[0m'
|
||||||
|
logger = '\u001b[0m'
|
||||||
|
message = '\u001b[0m'
|
||||||
|
marker = '\u001b[0m'
|
||||||
|
# level colors
|
||||||
|
TRACE.info = '\u001b[38;2;138;173;244m'
|
||||||
|
TRACE.message = '\u001b[38;2;138;173;244m'
|
||||||
|
FINE.info = '\u001b[38;2;198;160;246m'
|
||||||
|
FINE.message = '\u001b[38;2;198;160;246m'
|
||||||
|
DEBUG.info = '\u001b[38;2;133;138;149m'
|
||||||
|
DEBUG.message = '\u001b[38;2;133;138;149m'
|
||||||
|
ERROR.info = '\u001b[38;2;237;135;150m'
|
||||||
|
ERROR.message = '\u001b[38;2;237;135;150m'
|
||||||
|
WARNING.info = '\u001b[38;2;245;169;127m'
|
||||||
|
WARNING.message = '\u001b[38;2;245;169;127m'
|
||||||
|
FATAL.info = '\u001b[38;2;255;255;0;48;2;120;10;10m'
|
||||||
|
FATAL.message = '\u001b[38;2;255;255;0;48;2;120;10;10m'
|
||||||
|
FATAL.loggger = '\u001b[38;2;245;189;230m'
|
||||||
|
|
@ -9,16 +9,6 @@
|
|||||||
### Rename
|
### Rename
|
||||||
|
|
||||||
- `Api_version` -> `api_version`
|
- `Api_version` -> `api_version`
|
||||||
- `_DR_Status` -> `_DRStatus`
|
|
||||||
- `name` = `DR Option` -> `DR Status`
|
|
||||||
- 这毛病属实是没想到, 之前一直没发现
|
|
||||||
|
|
||||||
### Rework
|
|
||||||
|
|
||||||
- 将 `logging` 的依赖改为 `lib_not_dr.loggers`
|
|
||||||
- 以后都用 `lib_not_dr` 的 logger 了
|
|
||||||
- Change the dependency of `logging` to `lib_not_dr.loggers`
|
|
||||||
- Use `lib_not_dr` logger in the future
|
|
||||||
|
|
||||||
### Add
|
### Add
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit f0eb5480b5a973a458cdfd3e7e91ef695de064d4
|
Subproject commit 544c180e728d1b1f7942cb7874f6e579c1acc02b
|
@ -1 +1 @@
|
|||||||
Subproject commit 7df9ee869242f482579f1aa0ed5c61e39c4a444f
|
Subproject commit e5b5e24807687b1a12dca73ce3055a2745d38cf9
|
1116
libs/utils/logger-old.py
Normal file
1116
libs/utils/logger-old.py
Normal file
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,7 @@
|
|||||||
# All rights reserved
|
# All rights reserved
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
|
|
||||||
|
import logging
|
||||||
import warnings
|
import warnings
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
@ -15,11 +16,9 @@ from Difficult_Rocket.api.mod import ModInfo
|
|||||||
from Difficult_Rocket.client import ClientWindow
|
from Difficult_Rocket.client import ClientWindow
|
||||||
from Difficult_Rocket.api.types import Options, Version
|
from Difficult_Rocket.api.types import Options, Version
|
||||||
|
|
||||||
from lib_not_dr import loggers
|
|
||||||
|
|
||||||
DR_rust_version = Version("0.2.23.0") # DR_mod 的 Rust 编写部分的兼容版本
|
DR_rust_version = Version("0.2.23.0") # DR_mod 的 Rust 编写部分的兼容版本
|
||||||
|
|
||||||
logger = loggers.config.get_logger_from_old("client.dr_game", "client")
|
logger = logging.getLogger("client.dr_game")
|
||||||
|
|
||||||
|
|
||||||
class _DR_mod_runtime(Options): # NOQA
|
class _DR_mod_runtime(Options): # NOQA
|
||||||
|
@ -13,8 +13,12 @@ from lib_not_dr.nuitka import nuitka_config_type, raw_config_type
|
|||||||
|
|
||||||
def gen_pyglet_no_follow_import() -> list:
|
def gen_pyglet_no_follow_import() -> list:
|
||||||
no_follow_import = []
|
no_follow_import = []
|
||||||
no_follow_import += [f"pyglet.app.{x}" for x in ["win32", "xlib", "cocoa"]]
|
no_follow_import += [
|
||||||
no_follow_import += [f"pyglet.input.{x}" for x in ["win32", "linux", "macos"]]
|
f"pyglet.app.{x}" for x in ["win32", "xlib", "cocoa"]
|
||||||
|
]
|
||||||
|
no_follow_import += [
|
||||||
|
f"pyglet.input.{x}" for x in ["win32", "linux", "macos"]
|
||||||
|
]
|
||||||
no_follow_import += [
|
no_follow_import += [
|
||||||
f"pyglet.libs.{x}"
|
f"pyglet.libs.{x}"
|
||||||
for x in ["win32", "x11", "wayland", "darwin", "egl", "headless"]
|
for x in ["win32", "x11", "wayland", "darwin", "egl", "headless"]
|
||||||
@ -32,7 +36,9 @@ def gen_pyglet_no_follow_import() -> list:
|
|||||||
"headless",
|
"headless",
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
no_follow_import += [f"pyglet.gl.{x}" for x in ["win32", "xlib", "cocoa", "headless"]]
|
no_follow_import += [
|
||||||
|
f"pyglet.gl.{x}" for x in ["win32", "xlib", "cocoa", "headless"]
|
||||||
|
]
|
||||||
|
|
||||||
mult_plat_libs = ["app", "input", "libs", "window", "canvas", "gl"]
|
mult_plat_libs = ["app", "input", "libs", "window", "canvas", "gl"]
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
@ -53,15 +59,15 @@ def gen_pyglet_no_follow_import() -> list:
|
|||||||
|
|
||||||
|
|
||||||
def main(config: raw_config_type) -> nuitka_config_type:
|
def main(config: raw_config_type) -> nuitka_config_type:
|
||||||
print("debug", config)
|
print('debug', config)
|
||||||
config = config["cli"]
|
config = config['cli']
|
||||||
|
|
||||||
config["file-version"] = str(build_version)
|
config['file-version'] = str(build_version)
|
||||||
config["product-version"] = str(sdk_version)
|
config['product-version'] = str(sdk_version)
|
||||||
config["macos-app-version"] = str(sdk_version)
|
config['macos-app-version'] = str(sdk_version)
|
||||||
|
|
||||||
config["nofollow-import-to"] += gen_pyglet_no_follow_import()
|
config['nofollow-import-to'] += gen_pyglet_no_follow_import()
|
||||||
config["output-dir"] = "./build/nuitka-" + platform.system().lower()
|
config['output-dir'] = './build/nuitka-' + platform.system().lower()
|
||||||
|
|
||||||
print("done", config)
|
print('done', config)
|
||||||
return config
|
return config
|
||||||
|
Loading…
Reference in New Issue
Block a user