From 880269d9d81360b37483cbb110caf95491b9d973 Mon Sep 17 00:00:00 2001 From: GordonFreeman-BY Date: Mon, 24 Jan 2022 03:43:16 +0300 Subject: [PATCH] Add possibility to set loglevel from environment. --- example.env | 3 +++ olgram/settings.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/example.env b/example.env index d62510a..02b44f2 100644 --- a/example.env +++ b/example.env @@ -24,3 +24,6 @@ WEBHOOK_PORT=8443 CUSTOM_CERT=true REDIS_PATH=redis://redis + +# Set log level, can be CRITICAL, ERROR, WARNING, INFO, DEBUG. By default it set to INFO. +LOGLEVEL= diff --git a/olgram/settings.py b/olgram/settings.py index ef4ed2e..7ca0c3a 100644 --- a/olgram/settings.py +++ b/olgram/settings.py @@ -1,6 +1,6 @@ from dotenv import load_dotenv from abc import ABC -import os +import os, logging from olgram.utils.crypto import Cryptor from functools import lru_cache @@ -83,6 +83,7 @@ class ServerSettings(AbstractSettings): def append_text(cls) -> str: return "\n\nЭтот бот создан с помощью @OlgramBot" + logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO")) class BotSettings(AbstractSettings): @classmethod