I have a Fastapi API running with uvicorn. I use uvicorn logging like so:
if __name__ == "__main__":
uvicorn.run("main:app", host=host, port=int(port), reload=True, log_level=log_level,
log_config="config/logging.yaml")
What I would like to achive is beeing able to change the log_level through an endpoint. Something like:
@app.put("/api/log/{level}")
def change_log_level(level):
#something that changes the log level.
I tried to make a global variable log_level but it didn't work and I'm not sure how to change it as the log_level is in the uvicorn.run instruction. It is as well in the config.yaml file, so I'm not really sure were to change it...
I'm open to try the logging with another library if needed