Add possibility to set loglevel from environment.

This commit is contained in:
GordonFreeman-BY 2022-01-24 03:43:16 +03:00
parent d8b580d81b
commit 880269d9d8
2 changed files with 5 additions and 1 deletions

View File

@ -24,3 +24,6 @@ WEBHOOK_PORT=8443
CUSTOM_CERT=true CUSTOM_CERT=true
REDIS_PATH=redis://redis REDIS_PATH=redis://redis
# Set log level, can be CRITICAL, ERROR, WARNING, INFO, DEBUG. By default it set to INFO.
LOGLEVEL=

View File

@ -1,6 +1,6 @@
from dotenv import load_dotenv from dotenv import load_dotenv
from abc import ABC from abc import ABC
import os import os, logging
from olgram.utils.crypto import Cryptor from olgram.utils.crypto import Cryptor
from functools import lru_cache from functools import lru_cache
@ -83,6 +83,7 @@ class ServerSettings(AbstractSettings):
def append_text(cls) -> str: def append_text(cls) -> str:
return "\n\nЭтот бот создан с помощью @OlgramBot" return "\n\nЭтот бот создан с помощью @OlgramBot"
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
class BotSettings(AbstractSettings): class BotSettings(AbstractSettings):
@classmethod @classmethod