ErisPulse 2.1.7.post1__tar.gz → 2.1.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/PKG-INFO +1 -1
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/CHANGELOG.md +7 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/pyproject.toml +1 -1
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/src/ErisPulse/Core/__init__.py +23 -1
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/src/ErisPulse/Core/logger.py +46 -5
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/.github/assets/erispulse_logo.png +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/.github/tools/merge_md.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/.github/tools/update-api-docs.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/.github/workflows/auto-tag-release.yml +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/.github/workflows/pypi-publish.yml +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/.gitignore +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/.python-version +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/CODE_OF_CONDUCT.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/LICENSE +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/README.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/devs/test.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/devs/test_adapter.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/devs/test_files/test.docx +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/devs/test_files/test.jpg +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/devs/test_files/test.mp4 +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/AIDocs/ErisPulse-AdapterDev.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/AIDocs/ErisPulse-Core.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/AIDocs/ErisPulse-Full.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/AIDocs/ErisPulse-ModuleDev.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/AIDocs/README.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/AIModuleGeneration.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/AdapterStandards/APIResponse.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/AdapterStandards/EventConversion.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/AdapterStandards/README.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/CHANGELOG_1.x.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/CLI.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/Development/Adapter.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/Development/CLI.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/Development/Module.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/Development/README.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/PlatformFeatures.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/UseCore.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/api/ErisPulse/Core/adapter.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/api/ErisPulse/Core/env.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/api/ErisPulse/Core/logger.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/api/ErisPulse/Core/mods.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/api/ErisPulse/Core/raiserr.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/api/ErisPulse/Core/server.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/api/ErisPulse/Core/util.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/api/ErisPulse/__init__.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/api/ErisPulse/__main__.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/api/README.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/docs/quick-start.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-adapter/LICENSE +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-adapter/MyAdapter/Core.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-adapter/MyAdapter/__init__.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-adapter/README.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-adapter/pyproject.toml +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-cli-module/LICENSE +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-cli-module/README.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-cli-module/my_cli_module/__init__.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-cli-module/my_cli_module/cli.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-cli-module/pyproject.toml +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-module/LICENSE +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-module/MyModule/Core.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-module/MyModule/__init__.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-module/README.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-module/pyproject.toml +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/scripts/install/install.ps1 +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/scripts/install/install.sh +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/src/ErisPulse/Core/adapter.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/src/ErisPulse/Core/env.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/src/ErisPulse/Core/mods.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/src/ErisPulse/Core/raiserr.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/src/ErisPulse/Core/server.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/src/ErisPulse/Core/util.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/src/ErisPulse/__init__.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/src/ErisPulse/__main__.py +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/style_guide/DOCSTRING_SPEC.md +0 -0
- {erispulse-2.1.7.post1 → erispulse-2.1.8}/style_guide/README.md +0 -0
|
@@ -29,7 +29,29 @@ if _config is None:
|
|
|
29
29
|
"port": 8000,
|
|
30
30
|
"ssl_certfile": None,
|
|
31
31
|
"ssl_keyfile": None
|
|
32
|
+
},
|
|
33
|
+
"logger": {
|
|
34
|
+
"level": "INFO",
|
|
35
|
+
"log_files": [],
|
|
36
|
+
"memory_limit": 1000
|
|
32
37
|
}
|
|
33
38
|
}
|
|
34
39
|
env.setConfig("ErisPulse", defaultConfig)
|
|
35
|
-
_config = defaultConfig
|
|
40
|
+
_config = defaultConfig
|
|
41
|
+
|
|
42
|
+
if _config.get("server") is None:
|
|
43
|
+
_config["server"] = {
|
|
44
|
+
"host": "0.0.0.0",
|
|
45
|
+
"port": 8000,
|
|
46
|
+
"ssl_certfile": None,
|
|
47
|
+
"ssl_keyfile": None
|
|
48
|
+
}
|
|
49
|
+
env.setConfig("ErisPulse", _config)
|
|
50
|
+
|
|
51
|
+
if _config.get("logger") is None:
|
|
52
|
+
_config["logger"] = {
|
|
53
|
+
"level": "INFO",
|
|
54
|
+
"log_files": [],
|
|
55
|
+
"memory_limit": 1000
|
|
56
|
+
}
|
|
57
|
+
env.setConfig("ErisPulse", _config)
|
|
@@ -14,6 +14,8 @@ import logging
|
|
|
14
14
|
import inspect
|
|
15
15
|
import datetime
|
|
16
16
|
from typing import List, Dict, Any, Optional, Union, Type, Set, Tuple, FrozenSet
|
|
17
|
+
from rich.logging import RichHandler
|
|
18
|
+
from rich.console import Console
|
|
17
19
|
|
|
18
20
|
class Logger:
|
|
19
21
|
"""
|
|
@@ -28,15 +30,36 @@ class Logger:
|
|
|
28
30
|
{!--< /tips >!--}
|
|
29
31
|
"""
|
|
30
32
|
def __init__(self):
|
|
33
|
+
self._max_logs = 1000
|
|
31
34
|
self._logs = {}
|
|
32
35
|
self._module_levels = {}
|
|
33
36
|
self._logger = logging.getLogger("ErisPulse")
|
|
34
37
|
self._logger.setLevel(logging.DEBUG)
|
|
35
38
|
self._file_handler = None
|
|
36
39
|
if not self._logger.handlers:
|
|
37
|
-
console_handler =
|
|
38
|
-
|
|
40
|
+
console_handler = RichHandler(
|
|
41
|
+
console=Console(),
|
|
42
|
+
show_time=False,
|
|
43
|
+
show_level=True,
|
|
44
|
+
show_path=False,
|
|
45
|
+
markup=True
|
|
46
|
+
)
|
|
39
47
|
self._logger.addHandler(console_handler)
|
|
48
|
+
self._setup_config()
|
|
49
|
+
|
|
50
|
+
def set_memory_limit(self, limit: int) -> bool:
|
|
51
|
+
"""
|
|
52
|
+
设置日志内存存储上限
|
|
53
|
+
|
|
54
|
+
:param limit: 日志存储上限
|
|
55
|
+
:return: bool 设置是否成功
|
|
56
|
+
"""
|
|
57
|
+
if limit > 0:
|
|
58
|
+
self._max_logs = limit
|
|
59
|
+
return True
|
|
60
|
+
else:
|
|
61
|
+
self._logger.warning("日志存储上限必须大于0。")
|
|
62
|
+
return False
|
|
40
63
|
|
|
41
64
|
def set_level(self, level: str) -> bool:
|
|
42
65
|
"""
|
|
@@ -63,8 +86,8 @@ class Logger:
|
|
|
63
86
|
:param level: 日志级别(DEBUG/INFO/WARNING/ERROR/CRITICAL)
|
|
64
87
|
:return: bool 设置是否成功
|
|
65
88
|
"""
|
|
66
|
-
from .
|
|
67
|
-
if not
|
|
89
|
+
from .mods import mods
|
|
90
|
+
if not mods.get_module_status(module_name):
|
|
68
91
|
self._logger.warning(f"模块 {module_name} 未启用,无法设置日志等级。")
|
|
69
92
|
return False
|
|
70
93
|
level = level.upper()
|
|
@@ -93,7 +116,8 @@ class Logger:
|
|
|
93
116
|
for p in path:
|
|
94
117
|
try:
|
|
95
118
|
file_handler = logging.FileHandler(p, encoding='utf-8')
|
|
96
|
-
|
|
119
|
+
# 使用自定义格式化器去除rich markup标签
|
|
120
|
+
file_handler.setFormatter(logging.Formatter("[%(name)s] %(message)s"))
|
|
97
121
|
self._logger.addHandler(file_handler)
|
|
98
122
|
self._logger.info(f"日志输出已设置到文件: {p}")
|
|
99
123
|
return True
|
|
@@ -141,10 +165,27 @@ class Logger:
|
|
|
141
165
|
def _save_in_memory(self, ModuleName, msg):
|
|
142
166
|
if ModuleName not in self._logs:
|
|
143
167
|
self._logs[ModuleName] = []
|
|
168
|
+
|
|
169
|
+
# 检查日志数量是否超过限制
|
|
170
|
+
if len(self._logs[ModuleName]) >= self._max_logs:
|
|
171
|
+
self._logs[ModuleName].pop(0)
|
|
172
|
+
|
|
144
173
|
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
145
174
|
msg = f"{timestamp} - {msg}"
|
|
146
175
|
self._logs[ModuleName].append(msg)
|
|
147
176
|
|
|
177
|
+
def _setup_config(self):
|
|
178
|
+
from .env import env
|
|
179
|
+
_config = env.getConfig("ErisPulse")
|
|
180
|
+
if "logger" in _config:
|
|
181
|
+
logger_config = _config["logger"]
|
|
182
|
+
if "level" in logger_config:
|
|
183
|
+
self.set_level(logger_config["level"])
|
|
184
|
+
if "log_files" in logger_config and logger_config["log_files"]:
|
|
185
|
+
self.set_output_file(logger_config["log_files"])
|
|
186
|
+
if "memory_limit" in logger_config:
|
|
187
|
+
self.set_memory_limit(logger_config["memory_limit"])
|
|
188
|
+
|
|
148
189
|
def _get_effective_level(self, module_name):
|
|
149
190
|
return self._module_levels.get(module_name, self._logger.level)
|
|
150
191
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{erispulse-2.1.7.post1 → erispulse-2.1.8}/examples/example-cli-module/my_cli_module/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|