Hi,
I have noticed that Application.stop/1 calls are no longer being reported by erlang’s :error_logger in the same way with version 1.15.0. It was working with version 1.14.5.
See this sample module for an example. I use poison as the application to stop, but it could be any application that has started:
defmodule GenEventTester do
@moduledoc """
Documentation for `GenEventTester`.
"""
@behaviour :gen_event
require Logger
@impl :gen_event
def init(_) do
Logger.notice("init/1 has been called")
{:ok, %{}}
end
@impl :gen_event
def handle_event(msg, state) do
Logger.notice("handle_event/2 has been called: #{inspect(msg)}")
{:ok, state}
end
@impl :gen_event
def handle_call(msg, state) do
Logger.notice("handle_call/2 has been called: #{inspect(msg)}")
{:ok, :ok, state}
end
end
Running this with Elixir 1.14.5:
Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit:ns]
==> poison
Compiling 4 files (.ex)
Generated poison app
==> gen_event_tester
Compiling 1 file (.ex)
Generated gen_event_tester app
Interactive Elixir (1.14.5) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :error_logger.add_report_handler GenEventTester, []
09:08:57.338 [notice] init/1 has been called
:ok
iex(2)> Application.stop :poison
09:09:08.441 [notice] handle_event/2 has been called: {:info_report, #PID<0.70.0>, {#PID<0.44.0>, :std_info, [application: :poison, exited: :stopped, type: :temporary]}}
:ok
09:09:08.441 [notice] Application poison exited: :stopped
iex(3)>
Running this with Elixir 1.15.0:
Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit:ns]
Interactive Elixir (1.15.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :error_logger.add_report_handler GenEventTester, []
09:10:53.747 [notice] init/1 has been called
:ok
iex(2)> Application.stop :poison
09:11:08.419 [notice] Application poison exited: :stopped
:ok
iex(3)>
Interestingly, the gen_event behaviour is being used somewhat, as the init/1 callback is called.
Does anybody know how to get the handle_event/2 callbacks to be called with Elixir 1.15.0, and/or know why this is happening?