MRdotB
DiscoLog - Use Discord as a logging service and error tracking solution
Hello,
I’m excited to introduce DiscoLog, a logging service and error tracking solution for Elixir that uses a Discord server as its backend.
Setup
DiscoLog is easy to set up with a mix task that creates three channels for you:
#occurrences: A forum-style channel where errors are grouped by fingerprint and tagged, making it easy to track and manage them.#info: This channel pipes the output ofLogger.infodirectly to Discord, keeping you informed of general application events.#error: This channel pipes the output ofLogger.error. If the logger content is not an exception, it goes here; otherwise, it’s routed to#occurrences.
Additionally, DiscoLog have integration with Plug, Phoenix, LiveView, and Oban to provide extra context through :telemetry
Additionally, DiscoLog includes a :logger handler that converts exceptions into error occurrences, even for processes that lack specific integrations, such as GenServer crashes.
By using Discord, DiscoLog benefits from built-in notifications through the Discord app. Another advantage of the forum channel is the ability to prevent specific errors from triggering notifications repeatedly.
The Story Behind DiscoLog
DiscoLog is built upon the foundations of error_tracker, for the :logger handler, I borrows a lot of code from sentry-elixir and appsignal-elixir
The idea for DiscoLog emerged while experimenting with Discord’s Bot API. I realized that the Discord Forum Channel type could serve as a good solution for error tracking. The primary challenge was Discord’s limited message size, but I overcame this by utilizing message attachments to handle larger payloads.
Trending in Announcing
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance











First 10 of 16 Posts
dimitarvp
Wow that’s amazing, thanks for putting it together!
grzuy
Hi @MRdotB ,
This is great, thanks for sharing!
I wonder how easy an integration with tower can be so to have a
tower_discordpackage in order to be able to report errors both to Discord and other places at the same time.MRdotB
I’m not sure what value integrating with Tower brings. DiscoLog already has a logger handler, so after configuring the Logger backend, doing
Logger.error(some_exception)reports the error to the Discord backend. For telemetry, I also hook them and report separately. Adding DiscoLog to your app only requires modifying the config, with no additional code changes. Additionally, we have duplicate logic in event.ex, which I need for error tracking.grzuy
You’re right.
There’s too much overlap.
Makes more sense to have an hypothetical
tower_discordbe a separate package that only depends ontowerand maybe a Discord elixir client.Thanks
slouchpie
This is genius. Putting logs and error tracking into an app people are already using is such a smart idea. Well done!
MRdotB
I released disco_log v0.5.1:
Meanwhile I have been using it in production on multiples side projects.
I’m very satisfied with the error tracking !
Next features on my list are:
martosaur
I’ve only started using it but it’s been great so far. I like how setting up logging for multiple projects/environment is a matter of configuring category_id/channel_id.
I think I may have preferred starting DiscoLog under the application’s supervision tree and explicitly configuring logger handlers, but it might be too early to say
MRdotB
Thanks for your PR! It’s been released on Hex as version 0.6.
I considered allowing DiscoLog to start under an application’s supervision tree and using explicit logger handlers, but decided against it to keep the setup simpler. Everything started by the DiscoLog application is configurable, though, so it still allows flexibility. You can check out the setup in DiscoLog’s application module.
martosaur
I’ve been looking through the code recently, and I have a feeling that it’s feasible to allow users to start discolog under their supervision tree while maintaining the default option of running it as an independent application. Basically, it should boil down to only reading from global configuration on start up and then passing it to all downstream code (logger handler,
Discord.Client, etc.) through composition. So, it’s possible for users to just setenable: falsein global config and attach their own logger handlers with custom configuration.The problem is that it’s a lot of changes and I can’t think of too many use cases that it would unlock. I suppose, if you want to publish to multiple guilds or categories, that will make it possible. I’d still be happy to do this, as I just love the idea behind DiscoLog and want it to be awesome, but I don’t want to create a 1000 LOC refactoring PR out of the blue without your blessing
Do you think making DiscoLog highly configurable is worth it, or would you rather shelve the idea until some time in the future?
MRdotB
Sure, it’s possible to achieve this without a big LOC I think.
The clean approach would be to include a Supervisor in the DiscoLog module. After that, you could run it in your application like this:
In terms of configuration, there wouldn’t be much to change—just move the existing application logic in the supervisor. The current application would then call the supervisor instead.
For the logger handler, I think the current setup is fine. You can disable it and attach a custom handler yourself.
That said, I can’t think of specific use cases for this right now, but adding this feature would certainly make DiscoLog more flexible.
Oban is a great example of a library that give you a supervisor to start in your application.