diff --git a/lib/appsignal/logger/backend.ex b/lib/appsignal/logger/backend.ex index 30ea38126..7c57dcf93 100644 --- a/lib/appsignal/logger/backend.ex +++ b/lib/appsignal/logger/backend.ex @@ -1,20 +1,16 @@ defmodule Appsignal.Logger.Backend do @behaviour :gen_event - def init({__MODULE__, group}) do - {:ok, group} + def init({__MODULE__, options}) do + {:ok, Keyword.merge([group: "app"], options)} end - def init(_) do - {:ok, "app"} + def handle_event({level, _gl, {Logger, message, _timestamp, metadata}}, options) do + Appsignal.Logger.log(level, options[:group], IO.chardata_to_string(message), Enum.into(metadata, %{})) + {:ok, options} end - def handle_event({level, _gl, {Logger, message, _timestamp, metadata}}, group) do - Appsignal.Logger.log(level, group, IO.chardata_to_string(message), Enum.into(metadata, %{})) - {:ok, group} - end - - def handle_call(_messsage, group) do - {:ok, nil, group} + def handle_call(_messsage, options) do + {:ok, nil, options} end end diff --git a/test/appsignal/logger/backend_test.exs b/test/appsignal/logger/backend_test.exs index 5211f815c..32b5e5318 100644 --- a/test/appsignal/logger/backend_test.exs +++ b/test/appsignal/logger/backend_test.exs @@ -31,7 +31,7 @@ defmodule Appsignal.Logger.BackendTest do ] } }, - "phoenix" + [group: "phoenix"] ) assert [{"phoenix", 3, "foo bar baz", _}] = Appsignal.Test.Nif.get!(:log)