Set default log level to info
This commit is contained in:
parent
29757b2e7d
commit
e4308923b4
1 changed files with 3 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
from typing import Any, Dict, Optional, cast
|
||||
from typing import Any, Dict, Literal, Optional, cast
|
||||
|
||||
import uvicorn
|
||||
from fastapi import Depends, FastAPI, HTTPException, Request, status
|
||||
|
|
@ -15,6 +15,7 @@ from ops_bot.matrix import MatrixClient, MatrixClientSettings
|
|||
class BotSettings(BaseSettings):
|
||||
bearer_token: str
|
||||
routing_keys: Dict[str, str]
|
||||
log_level: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = "INFO"
|
||||
|
||||
class Config:
|
||||
env_prefix = "BOT_"
|
||||
|
|
@ -40,6 +41,7 @@ async def matrix_main(matrix_client: MatrixClient) -> None:
|
|||
@app.on_event("startup")
|
||||
async def startup_event() -> None:
|
||||
bot_settings = BotSettings(_env_file=".env", _env_file_encoding="utf-8")
|
||||
logging.getLogger().setLevel(bot_settings.log_level)
|
||||
matrix_settings = MatrixClientSettings(_env_file=".env", _env_file_encoding="utf-8")
|
||||
matrix_settings.join_rooms = list(bot_settings.routing_keys.values())
|
||||
c = MatrixClient(settings=matrix_settings)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue