mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-21 21:58:04 +00:00
🐛 fix logger config
Signed-off-by: Karako <karakohear@gmail.com>
This commit is contained in:
parent
f0b287dcfe
commit
fe9c1261a0
@ -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_"
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user