Created
January 8, 2020 22:02
-
-
Save Rested/3ff7d407518cfd691dd5f7f0f6bdf8a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pydantic | |
from enum import Enum | |
import logging | |
class LogLevelEnum(Enum): | |
CRITICAL = "CRITICAL" | |
ERROR = "ERROR" | |
WARNING = "WARNING" | |
INFO = "INFO" | |
DEBUG = "DEBUG" | |
NOTSET = "NOTSET" | |
class Settings(pydantic.BaseSettings): | |
postgres_dsn: pydantic.PostgresDsn | |
db_connect_timeout_seconds: int = 10 | |
log_level: LogLevelEnum = LogLevelEnum.INFO | |
settings = Settings() | |
logging.basicConfig(level=settings.log_level.value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Set a log level with pydantic settings!