From 848bd65b115a605a7c918f6abc0a115be41e1123 Mon Sep 17 00:00:00 2001 From: Hannah Purcell <69368883+hannahpurcell@users.noreply.github.com> Date: Thu, 6 Feb 2025 17:13:44 -0500 Subject: [PATCH] tweak: Log on trip mod publication (#2951) --- lib/skate/detours/trip_modification_publisher.ex | 7 ++++++- lib/skate_web/controllers/detours_controller.ex | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/skate/detours/trip_modification_publisher.ex b/lib/skate/detours/trip_modification_publisher.ex index ea3c1ea00..6946c6a68 100644 --- a/lib/skate/detours/trip_modification_publisher.ex +++ b/lib/skate/detours/trip_modification_publisher.ex @@ -1,5 +1,7 @@ defmodule Skate.Detours.TripModificationPublisher do @behaviour Skate.Detours.TripModificationPublisher + require Logger + @moduledoc """ Connects to the MQTT Broker, then allows sending `Realtime.TripModification`'s to the Broker. @@ -152,9 +154,12 @@ defmodule Skate.Detours.TripModificationPublisher do # Send at least once qos: 1 }) do + Logger.info(fn -> "publish_modification: message successfully sent" end) :ok else - res -> res + {:error, error} -> + Logger.warning(fn -> "publish_modification returned error: #{error}" end) + {:error, error} end { diff --git a/lib/skate_web/controllers/detours_controller.ex b/lib/skate_web/controllers/detours_controller.ex index f9a784247..1c3abece7 100644 --- a/lib/skate_web/controllers/detours_controller.ex +++ b/lib/skate_web/controllers/detours_controller.ex @@ -1,4 +1,5 @@ defmodule SkateWeb.DetoursController do + require Logger alias Realtime.Shape alias Realtime.TripModification alias Skate.OpenRouteServiceAPI @@ -125,7 +126,9 @@ defmodule SkateWeb.DetoursController do trip_modification_publisher().publish_modification(modification, shape, is_draft?: true) catch # May throw if the publishing server doesn't exist, which we can ignore. - :exit, {:noproc, _} -> nil + :exit, {:noproc, _} -> + Logger.warning(fn -> "trip_modification_publisher: Publishing server not found" end) + nil end end