Skip to content

MatthewScholefield/uvicorn-loguru-integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Uvicorn Loguru Integration

Code to integrate uvicorn.run with Loguru logging

Loguru is a great alternative logging library for Python. However, since Uvicorn uses Python's standard logging library, using Loguru looks inconsistent. This module injects an intercept handler in the correct location after initializing Uvicorn so that all logs get routed through Loguru.

Usage

Call run_uvicorn_loguru with an instance of uvicorn.Config:

from uvicorn_loguru_integration import run_uvicorn_loguru


def main():
    run_uvicorn_loguru(
        uvicorn.Config(
            "myapp:app",
            host="0.0.0.0",
            port=8000,
            log_level="info",
            reload=True,
        )
    )


if __name__ == "__main__":
    main()

Installation

Install via pip:

pip3 install uvicorn-loguru-integration

About

Code to integrate uvicorn.run with Loguru logging

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages