add config for disable network warning log

This commit is contained in:
felinae98 2023-03-26 20:32:02 +08:00
parent 560fd81db6
commit 2796ea6f8e
3 changed files with 9 additions and 5 deletions

View File

@ -148,6 +148,7 @@ sidebar: auto
- `BISON_PROXY`: 使用的代理连接,形如`http://<ip>:<port>`(可选)
- `BISON_UA`: 使用的 User-Agent默认为 Chrome
- `BISON_SHOW_NETWORK_WARNING`: 是否在日志中输出网络异常,默认开启
## 使用

View File

@ -93,14 +93,16 @@ class Platform(metaclass=PlatformABCMeta, base=True):
try:
return await self.fetch_new_post(target, users)
except httpx.RequestError as err:
logger.warning(
"network connection error: {}, url: {}".format(
type(err), err.request.url
if plugin_config.bison_show_network_warning:
logger.warning(
"network connection error: {}, url: {}".format(
type(err), err.request.url
)
)
)
return []
except ssl.SSLError as err:
logger.warning(f"ssl error: {err}")
if plugin_config.bison_show_network_warning:
logger.warning(f"ssl error: {err}")
return []
except json.JSONDecodeError as err:
logger.warning(f"json error, parsing: {err.doc}")

View File

@ -19,6 +19,7 @@ class PlugConfig(BaseSettings):
bison_resend_times: int = 0
bison_proxy: Optional[str]
bison_ua: str = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
bison_show_network_warning: bool = True
class Config:
extra = "ignore"