mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-27 18:45:05 +08:00
🔥 remove debug option
This commit is contained in:
parent
3323393261
commit
f06b78054c
@ -262,11 +262,7 @@ def init(*, _env_file: Optional[str] = None, **kwargs):
|
||||
_env_file=_env_file or f".env.{env.environment}",
|
||||
)
|
||||
|
||||
default_filter.level = (
|
||||
("DEBUG" if config.debug else "INFO")
|
||||
if config.log_level is None
|
||||
else config.log_level
|
||||
)
|
||||
default_filter.level = config.log_level
|
||||
logger.opt(colors=True).info(
|
||||
f"Current <y><b>Env: {escape_tag(env.environment)}</b></y>"
|
||||
)
|
||||
|
@ -189,19 +189,10 @@ class Config(BaseConfig):
|
||||
|
||||
NoneBot 的 HTTP 和 WebSocket 服务端监听的端口。
|
||||
"""
|
||||
debug: bool = False
|
||||
"""
|
||||
- **类型**: ``bool``
|
||||
- **默认值**: ``False``
|
||||
|
||||
:说明:
|
||||
|
||||
是否以调试模式运行 NoneBot。
|
||||
"""
|
||||
log_level: Optional[Union[int, str]] = None
|
||||
log_level: Union[int, str] = "INFO"
|
||||
"""
|
||||
- **类型**: ``Union[int, str]``
|
||||
- **默认值**: ``None``
|
||||
- **默认值**: ``INFO``
|
||||
|
||||
:说明:
|
||||
|
||||
|
@ -63,15 +63,15 @@ class Config(BaseSettings):
|
||||
|
||||
``redoc`` 地址,默认为 ``None`` 即关闭
|
||||
"""
|
||||
fastapi_reload: Optional[bool] = None
|
||||
fastapi_reload: bool = False
|
||||
"""
|
||||
:类型:
|
||||
|
||||
``Optional[bool]``
|
||||
``bool``
|
||||
|
||||
:说明:
|
||||
|
||||
开启/关闭冷重载,默认会在配置了 app 的 debug 模式启用
|
||||
开启/关闭冷重载
|
||||
"""
|
||||
fastapi_reload_dirs: Optional[List[str]] = None
|
||||
"""
|
||||
@ -127,7 +127,6 @@ class Driver(ReverseDriver):
|
||||
self.fastapi_config: Config = Config(**config.dict())
|
||||
|
||||
self._server_app = FastAPI(
|
||||
debug=config.debug,
|
||||
openapi_url=self.fastapi_config.fastapi_openapi_url,
|
||||
docs_url=self.fastapi_config.fastapi_docs_url,
|
||||
redoc_url=self.fastapi_config.fastapi_redoc_url,
|
||||
@ -221,14 +220,11 @@ class Driver(ReverseDriver):
|
||||
app or self.server_app, # type: ignore
|
||||
host=host or str(self.config.host),
|
||||
port=port or self.config.port,
|
||||
reload=self.fastapi_config.fastapi_reload
|
||||
if self.fastapi_config.fastapi_reload is not None
|
||||
else (bool(app) and self.config.debug),
|
||||
reload=self.fastapi_config.fastapi_reload,
|
||||
reload_dirs=self.fastapi_config.fastapi_reload_dirs,
|
||||
reload_delay=self.fastapi_config.fastapi_reload_delay,
|
||||
reload_includes=self.fastapi_config.fastapi_reload_includes,
|
||||
reload_excludes=self.fastapi_config.fastapi_reload_excludes,
|
||||
debug=self.config.debug,
|
||||
log_config=LOGGING_CONFIG,
|
||||
**kwargs,
|
||||
)
|
||||
|
@ -40,15 +40,15 @@ class Config(BaseSettings):
|
||||
Quart 驱动框架设置
|
||||
"""
|
||||
|
||||
quart_reload: Optional[bool] = None
|
||||
quart_reload: bool = False
|
||||
"""
|
||||
:类型:
|
||||
|
||||
``Optional[bool]``
|
||||
``bool``
|
||||
|
||||
:说明:
|
||||
|
||||
开启/关闭冷重载,默认会在配置了 app 的 debug 模式启用
|
||||
开启/关闭冷重载
|
||||
"""
|
||||
quart_reload_dirs: Optional[List[str]] = None
|
||||
"""
|
||||
@ -199,14 +199,11 @@ class Driver(ReverseDriver):
|
||||
app or self.server_app, # type: ignore
|
||||
host=host or str(self.config.host),
|
||||
port=port or self.config.port,
|
||||
reload=self.quart_config.quart_reload
|
||||
if self.quart_config.quart_reload is not None
|
||||
else (bool(app) and self.config.debug),
|
||||
reload=self.quart_config.quart_reload,
|
||||
reload_dirs=self.quart_config.quart_reload_dirs,
|
||||
reload_delay=self.quart_config.quart_reload_delay,
|
||||
reload_includes=self.quart_config.quart_reload_includes,
|
||||
reload_excludes=self.quart_config.quart_reload_excludes,
|
||||
debug=self.config.debug,
|
||||
log_config=LOGGING_CONFIG,
|
||||
**kwargs,
|
||||
)
|
||||
|
@ -31,7 +31,7 @@ logger: "Logger" = loguru.logger
|
||||
:默认信息:
|
||||
|
||||
* 格式: ``[%(asctime)s %(name)s] %(levelname)s: %(message)s``
|
||||
* 等级: ``DEBUG`` / ``INFO`` ,根据 config 配置改变
|
||||
* 等级: ``INFO`` ,根据 ``config,log_level`` 配置改变
|
||||
* 输出: 输出至 stdout
|
||||
|
||||
:用法:
|
||||
@ -49,7 +49,7 @@ logger: "Logger" = loguru.logger
|
||||
|
||||
class Filter:
|
||||
def __init__(self) -> None:
|
||||
self.level: Union[int, str] = "DEBUG"
|
||||
self.level: Union[int, str] = "INFO"
|
||||
|
||||
def __call__(self, record):
|
||||
module_name: str = record["name"]
|
||||
|
@ -4,8 +4,6 @@ import inspect
|
||||
from types import ModuleType
|
||||
from typing import Any, Set, Dict, List, Type, Tuple, Union, Optional
|
||||
|
||||
from nonebot.params import State
|
||||
from nonebot.adapters import Event
|
||||
from nonebot.matcher import Matcher
|
||||
from .manager import _current_plugin
|
||||
from nonebot.permission import Permission
|
||||
|
@ -155,7 +155,7 @@ def logger_wrapper(logger_name: str):
|
||||
|
||||
:log 参数:
|
||||
|
||||
* ``level: Literal['WARNING', 'DEBUG', 'INFO']``: 日志等级
|
||||
* ``level: Literal["CRETICAL", "WARNING", "INFO", "DEBUG", "TRACE"]``: 日志等级
|
||||
* ``message: str``: 日志信息
|
||||
* ``exception: Optional[Exception]``: 异常信息
|
||||
"""
|
||||
|
@ -62,6 +62,8 @@ FastAPI: [文档](https://fastapi.tiangolo.com/), [仓库](https://github.com/ti
|
||||
DRIVER=~fastapi
|
||||
```
|
||||
|
||||
<!-- TODO: 配置项 -->
|
||||
|
||||
### Quart
|
||||
|
||||
类型: `ReverseDriver`
|
||||
|
@ -65,7 +65,6 @@ NoneBot 默认会从 `.env.{ENVIRONMENT}` 文件加载配置,但是可以在 N
|
||||
```bash
|
||||
HOST=0.0.0.0 # 配置 NoneBot 监听的 IP/主机名
|
||||
PORT=8080 # 配置 NoneBot 监听的端口
|
||||
DEBUG=true # 开启 debug 模式 **请勿在生产环境开启**
|
||||
SUPERUSERS=["123456789", "987654321"] # 配置 NoneBot 超级用户
|
||||
NICKNAME=["awesome", "bot"] # 配置机器人的昵称
|
||||
COMMAND_START=["/", ""] # 配置命令起始字符
|
||||
|
Loading…
Reference in New Issue
Block a user