Skip to content

Commit

Permalink
Merge pull request #30 from otobus/mustafaturan/update_logger_msg
Browse files Browse the repository at this point in the history
Update log message for empty subscribers
  • Loading branch information
Mustafa TURAN authored May 29, 2018
2 parents 90d515d + 212de9f commit 779361c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/event_bus/services/notification.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ defmodule EventBus.Service.Notification do
listeners = Subscription.subscribers(topic)

if listeners == [] do
Logger.log(@logging_level, "Topic :#{topic} listener set is empty!")
Logger.log(
@logging_level,
"Topic(:#{topic}#{registration_status(topic)}) doesn't have subscribers"
)
else
:ok = Store.create(event)
:ok = Observation.create({listeners, topic, id})
Expand Down Expand Up @@ -45,6 +48,11 @@ defmodule EventBus.Service.Notification do
Observation.mark_as_skipped({listener, topic, id})
end

@spec registration_status(atom()) :: String.t()
defp registration_status(topic) do
if EventBus.topic_exist?(topic), do: "", else: " doesn't exist!"
end

@spec log(module(), any()) :: no_return()
defp log(listener, error) do
msg = "#{listener}.process/1 raised an error!\n#{inspect(error)}"
Expand Down

0 comments on commit 779361c

Please sign in to comment.