Create a streaming log viewer using FastAPI

Overview

Many times, you need to view the latest log entries generated by your app to check that everything is working or see what is currently broken. We created a FastAPI app that will stream our latest log files entries over websockets. The blog post with more detail is available here:

Repo structure and file descriptions

  • main.py: FastAPI web server using uvicorn. Contains the log viewer page and websocket endpoints.
  • log-generator.py: Random log entry generator used for testing purposes.
  • templates/index.html: Log viewer page (client) which established websocket connection to server (main.py).

The dependencies and virtual environment details are located in the Pipfile which can be used with pipenv.

License

GNU GPL v3

Author

Coenraad Pretorius