From 212de9ff7f7917252e9177cc97c47d06d37af9be Mon Sep 17 00:00:00 2001 From: Mustafa Turan Date: Tue, 29 May 2018 01:08:17 -0700 Subject: [PATCH] Update log message for empty subscribers --- lib/event_bus/services/notification.ex | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/event_bus/services/notification.ex b/lib/event_bus/services/notification.ex index 326d73a..1ad05af 100644 --- a/lib/event_bus/services/notification.ex +++ b/lib/event_bus/services/notification.ex @@ -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}) @@ -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)}"