🐛 fix logger config

Signed-off-by: Karako <karakohear@gmail.com>
This commit is contained in:
Karako 2022-10-28 15:39:17 +08:00
parent f0b287dcfe
commit fe9c1261a0
No known key found for this signature in database
GPG Key ID: 5920831B0095D4A0
2 changed files with 9 additions and 13 deletions

View File

@ -7,15 +7,11 @@ from typing import (
)
import dotenv
from pydantic import (
AnyUrl,
BaseModel,
Field,
validator,
)
from pydantic import AnyUrl, BaseModel, Field
from utils.const import PROJECT_ROOT
from utils.models.base import Settings
from utils.typedefs import NaturalNumber
__all__ = ["BotConfig", "config", "JoinGroups"]
@ -67,15 +63,9 @@ class LoggerConfig(Settings):
render_keywords: List[str] = ["BOT"]
locals_max_length: int = 10
locals_max_string: int = 80
locals_max_depth: Optional[int] = None
locals_max_depth: Optional[NaturalNumber] = None
filtered_names: List[str] = ["uvicorn"]
@validator("locals_max_depth", pre=True, check_fields=False)
def locals_max_depth_validator(cls, value) -> Optional[int]: # pylint: disable=R0201
if int(value) <= 0:
return None
return value
class Config(Settings.Config):
env_prefix = "logger_"

View File

@ -4,6 +4,7 @@ from types import TracebackType
from typing import Any, Callable, Dict, Optional, Tuple, Type, Union
from httpx import URL
from pydantic import ConstrainedInt
__all__ = [
"StrOrPath",
@ -14,6 +15,7 @@ __all__ = [
"JSONDict",
"JSONType",
"LogFilterType",
"NaturalNumber",
]
StrOrPath = Union[str, Path]
@ -26,3 +28,7 @@ JSONDict = Dict[str, Any]
JSONType = Union[JSONDict, list]
LogFilterType = Union[Filter, Callable[[LogRecord], int]]
class NaturalNumber(ConstrainedInt):
ge = 0