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 asyncio
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict, Optional, cast
|
from typing import Any, Dict, Literal, Optional, cast
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi import Depends, FastAPI, HTTPException, Request, status
|
from fastapi import Depends, FastAPI, HTTPException, Request, status
|
||||||
|
|
@ -15,6 +15,7 @@ from ops_bot.matrix import MatrixClient, MatrixClientSettings
|
||||||
class BotSettings(BaseSettings):
|
class BotSettings(BaseSettings):
|
||||||
bearer_token: str
|
bearer_token: str
|
||||||
routing_keys: Dict[str, str]
|
routing_keys: Dict[str, str]
|
||||||
|
log_level: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = "INFO"
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
env_prefix = "BOT_"
|
env_prefix = "BOT_"
|
||||||
|
|
@ -40,6 +41,7 @@ async def matrix_main(matrix_client: MatrixClient) -> None:
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
async def startup_event() -> None:
|
async def startup_event() -> None:
|
||||||
bot_settings = BotSettings(_env_file=".env", _env_file_encoding="utf-8")
|
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 = MatrixClientSettings(_env_file=".env", _env_file_encoding="utf-8")
|
||||||
matrix_settings.join_rooms = list(bot_settings.routing_keys.values())
|
matrix_settings.join_rooms = list(bot_settings.routing_keys.values())
|
||||||
c = MatrixClient(settings=matrix_settings)
|
c = MatrixClient(settings=matrix_settings)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue