diff options
Diffstat (limited to 'lib/irc/plugin_supervisor.ex')
-rw-r--r-- | lib/irc/plugin_supervisor.ex | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/irc/plugin_supervisor.ex b/lib/irc/plugin_supervisor.ex index ca092dc..5f93f17 100644 --- a/lib/irc/plugin_supervisor.ex +++ b/lib/irc/plugin_supervisor.ex @@ -3,15 +3,24 @@ defmodule IRC.Plugin do defmodule Supervisor do use DynamicSupervisor + require Logger def start_link() do DynamicSupervisor.start_link(__MODULE__, [], name: __MODULE__) end def start_child(module, opts \\ []) do - IO.inspect(module) + Logger.info("Starting #{module}") spec = %{id: {IRC.Plugin,module}, start: {IRC.Plugin, :start_link, [module, opts]}, name: module, restart: :transient} - DynamicSupervisor.start_child(__MODULE__, spec) + case DynamicSupervisor.start_child(__MODULE__, spec) do + {:ok, _} = res -> res + :ignore -> + Logger.info("Ignored #{module}") + :ignore + {:error,_} = res -> + Logger.error("Could not start #{module}: #{inspect(res, pretty: true)}") + res + end end @impl true @@ -88,4 +97,3 @@ defmodule IRC.Plugin do end end - |