Closed ityonemo closed 3 years ago
NB: in order to use, you must include in Elixir Logger Backends, (you can't use the system that is in the docs)
I'm not familiar with this library or what needs to get done to get it working in Elixir 1.9 but I'm currently working on an app using Elixir 1.9 and would like to Rollbax integrated into it. Any status on this front or things you may need to get that done?
I can confirm that my fork works and has been working well in production for several months now (ymmv), but I don't know what the status of this library is.
@agundy I'm sorry but i just looked at my code and there's way too much private information in my logger gen_event module to copy/paste it publically here for you. I am currently slammed at work (it appears demand for our service goes up with the stay at home situation) but can maybe get to doing a better writeup in 2-3 weeks time, if you ping me then. I'm sorry I can't be more helpful, but I suggest reading these resources:
https://hexdocs.pm/logger/Logger.html#module-custom-backends http://erlang.org/doc/man/gen_event.html
but basically it boils down to writing handle_events that look like this:
defmodule Rollbax.ErrorLogger do
@behaviour :gen_event
import LogTag
@impl true
@spec init(any) :: {:ok, nil}
def init(_), do: {:ok, nil}
@impl true
def handle_call({:configure, _options}, state) do
{:ok, :ok, state}
end
@impl true
def handle_event(:flush, state) do
{:ok, state}
end
def handle_event({:error, gl, {Logger, msg, _timestamp, metas}}, state)
when node(gl) == node() do
# ...snip
Rollbax.report_message(:error, msg, custom)
{:ok, state}
end
def handle_event({:info, gl, {Logger, msg, _timestamp, metas}}, state)
when node(gl) == node() do
# ...snip
Rollbax.report_message(:info, msg, custom)
{:ok, state}
end
def handle_event(_, state) do
{:ok, state}
end
end
and registering that logger with your backends in your config.exs
@ityonemo thanks so much for the quick response! I'm still evaluating options and am checking out Sentry right now because it seems like they have first party support for Elixir. I might be back to check this out. And no worries on not being able to handle it right now! I know how you feel.
I'm no longer using rollbar in prod so this is left an an exercise for the next user.
tentative PR to look for comments and interest. Will finish with full parsing, tests, and documentation over the next month.
one note: