New to Elixir, trying to explore the language and idiomatic problem solving, mostly for fun and personal projects.
As a learning project, i’m trying to setup a dynamic HTTP server in order to play around with networking capabilities, concurrency and such.
I’ve got a basic HTTP server setup using Plug & Cowboy(directly), and got to have a simple streaming endpoint working.
Now, I’m wanting to expose internal log streams, and later on monitoring metrics, through HTTP endpoints.
That is, I want to hook into the logging subsystem of my application(or whatever process supervisor is shepherding everything), and get a hold of the live stream of log messages and expose them to the HTTP endpoint.
From my understanding, logs are managed through a process tree, consisting of one or many logging backends processing the log messages sent to that process group.
Am I right that in order to do what I want, I would have to
- Implement and configure a Logging backend(or perhaps a handler?) that implements all the proper interfaces to receive log messages through the Logging subsystem and distribute them to other interested processes(through some sort of internal PubSub protocol)
- Each time a connection is established to the endpoint, the request handler process subscribes to the custom logging backend and streams back logging messages to the http requester as they are received.
So this can be done in two parts, the logging backend, and the http endpoint.
Is there something that can already do this kind of internal log routing and minimize the work needed for the Logging backend part?
Are there simple examples of Logging backends and internal pub-sub/router processes that can guide me a bit?