Skip to content

Commit

Permalink
🔥 移除 LogConfig 配置类
Browse files Browse the repository at this point in the history
  • Loading branch information
A-kirami committed Apr 11, 2024
1 parent f3bfbfe commit e86fd9d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
3 changes: 0 additions & 3 deletions kirami/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,5 @@
server_config = kirami_config.server
"""服务器相关配置"""

log_config = kirami_config.log
"""日志相关配置"""

database_config = kirami_config.database
"""数据库相关配置"""
15 changes: 5 additions & 10 deletions kirami/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ def load_config(cls, namespace: str | None = None) -> Self:
return cls(**cls.__raw_config__.get(namespace, {}))


class LogConfig(BaseConfig):
log_expire_timeout: int = 7
"""日志文件过期时间"""


class DatabaseConfig(BaseConfig):
"""
MongoDB 数据库配置
Expand Down Expand Up @@ -164,10 +159,13 @@ class BotConfig(BaseConfig):
"""是否以调试模式运行 KiramiBot"""

log_level: LevelName | int = "INFO"
"""配置 KiramiBot 日志输出等级,可以为 `int` 类型等级或等级名称,参考 [loguru 日志等级](https://loguru.readthedocs.io/en/stable/api/logger.html#levels)"""
"""日志输出等级,可以为 `int` 类型等级或等级名称,参考 [loguru 日志等级](https://loguru.readthedocs.io/en/stable/api/logger.html#levels)"""

log_file: LevelName | tuple[LevelName] = "ERROR"
"""KiramiBot 的日志保存等级,必须为等级名称"""
"""日志保存等级,必须为等级名称"""

log_expire_timeout: int = 7
"""日志文件过期时间"""

api_root: dict[str, str] = {}
"""以机器人 ID 为键,上报地址为值的字典"""
Expand Down Expand Up @@ -241,9 +239,6 @@ class KiramiConfig(BaseConfig):
server: ServerConfig
"""服务器相关配置"""

log: LogConfig
"""日志相关配置"""

database: DatabaseConfig
"""数据库相关配置"""

Expand Down
4 changes: 2 additions & 2 deletions kirami/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from rich.theme import Theme
from rich.traceback import install

from kirami.config import LOG_DIR, bot_config, log_config
from kirami.config import LOG_DIR, bot_config

if TYPE_CHECKING:
from loguru import Logger as LoggerType
Expand Down Expand Up @@ -207,7 +207,7 @@ def __call__(self, record: "Record") -> bool:
"rotation": "00:00",
"enqueue": True,
"encoding": "utf-8",
"retention": f"{log_config.log_expire_timeout} days",
"retention": f"{bot_config.log_expire_timeout} days",
}


Expand Down

0 comments on commit e86fd9d

Please sign in to comment.