Skip to content

Commit

Permalink
Add logging for commish emails
Browse files Browse the repository at this point in the history
  • Loading branch information
axelclark committed Apr 5, 2024
1 parent e193cc3 commit 219809c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/ex338_web/controllers/commish_email_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ defmodule Ex338Web.CommishEmailController do
alias Ex338.Repo
alias Ex338Web.CommishNotifier

require Logger

def new(conn, _params) do
render(
conn,
Expand All @@ -20,12 +22,16 @@ defmodule Ex338Web.CommishEmailController do
result = CommishNotifier.send_email_to_leagues(leagues, subject, message)

case result do
{:ok, _result} ->
{:ok, result} ->
Logger.info("Commish email sent successfully: #{inspect(result)}")

conn
|> put_flash(:info, "Email sent successfully")
|> redirect(to: ~p"/commish_email/new")

{:error, reason} ->
Logger.error("Commish email failed: #{inspect(reason)}")

conn
|> put_flash(:error, "Email failed to send: #{reason}")
|> redirect(to: ~p"/commish_email/new")
Expand Down

0 comments on commit 219809c

Please sign in to comment.