feat: 支持设置控制台日志级别;
refactor: 重写了后端与仪表盘的日志通信
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
from asyncio import Queue
|
||||
from collections import deque
|
||||
from typing import Deque
|
||||
|
||||
class CachedQueue(Queue):
|
||||
def __init__(self, maxsize: int = 0, cachesize: int = 200):
|
||||
super().__init__(maxsize)
|
||||
self.cache = deque(maxlen=cachesize)
|
||||
|
||||
def put_nowait(self, item):
|
||||
self.cache.append(item)
|
||||
super().put_nowait(item)
|
||||
|
||||
def get_nowait(self):
|
||||
item = super().get_nowait()
|
||||
return item
|
||||
|
||||
def get(self):
|
||||
item = super().get()
|
||||
return item
|
||||
|
||||
def clear(self):
|
||||
self.cache.clear()
|
||||
with self.mutex:
|
||||
self._queue.clear()
|
||||
|
||||
def get_cache(self) -> Deque:
|
||||
return self.cache
|
||||
@@ -169,6 +169,7 @@ DEFAULT_CONFIG_VERSION_2 = {
|
||||
"username": "",
|
||||
"password": "",
|
||||
},
|
||||
"log_level": "INFO",
|
||||
}
|
||||
|
||||
# 这个是用于迁移旧版本配置文件的映射表
|
||||
@@ -350,4 +351,5 @@ CONFIG_METADATA_2 = {
|
||||
"password": {"description": "密码", "type": "string"},
|
||||
}
|
||||
},
|
||||
"log_level": {"description": "控制台日志级别(DEBUG, INFO, WARNING, ERROR)", "type": "string"},
|
||||
}
|
||||
|
||||
+3
-1
@@ -13,7 +13,7 @@ from type.middleware import Middleware
|
||||
from type.astrbot_message import MessageType
|
||||
from model.plugin.command import PluginCommandBridge
|
||||
from model.provider.provider import Provider
|
||||
from util.agent.func_call import FuncCall
|
||||
from type.cached_queue import CachedQueue
|
||||
|
||||
|
||||
class Context:
|
||||
@@ -49,6 +49,8 @@ class Context:
|
||||
self.command_manager = None
|
||||
self.running = True
|
||||
|
||||
self._log_queue = CachedQueue()
|
||||
|
||||
# useless
|
||||
# self.reply_prefix = ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user