Improve worker logging
This commit is contained in:
@@ -14,8 +14,6 @@ defmodule MusicLibrary.ScrobbleRules.Worker do
|
|||||||
|
|
||||||
@impl Oban.Worker
|
@impl Oban.Worker
|
||||||
def perform(%Oban.Job{args: _}) do
|
def perform(%Oban.Job{args: _}) do
|
||||||
Logger.info("Starting scrobble rules application")
|
|
||||||
|
|
||||||
results = ScrobbleRules.apply_all_rules()
|
results = ScrobbleRules.apply_all_rules()
|
||||||
log_results(results)
|
log_results(results)
|
||||||
end
|
end
|
||||||
@@ -35,26 +33,19 @@ defmodule MusicLibrary.ScrobbleRules.Worker do
|
|||||||
|> Enum.map(fn {:ok, {_, _, count}} -> count end)
|
|> Enum.map(fn {:ok, {_, _, count}} -> count end)
|
||||||
|> Enum.sum()
|
|> Enum.sum()
|
||||||
|
|
||||||
Logger.info("Scrobble rules application completed", %{
|
Logger.info(fn ->
|
||||||
rules_applied: total_applied,
|
"Scrobble rules application completed: " <>
|
||||||
rules_failed: total_errors,
|
"applied #{total_applied} rules, " <>
|
||||||
tracks_updated: total_tracks_updated
|
"#{total_errors} errors, " <>
|
||||||
})
|
"#{total_tracks_updated} tracks updated"
|
||||||
|
|
||||||
# Log individual rule results
|
|
||||||
Enum.each(applied, fn {:ok, {type, match_value, count}} ->
|
|
||||||
Logger.info("Applied #{type} rule", %{
|
|
||||||
match_value: match_value,
|
|
||||||
tracks_updated: count
|
|
||||||
})
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
# Log errors
|
|
||||||
Enum.each(errors, fn {:error, {type, match_value, reason}} ->
|
Enum.each(errors, fn {:error, {type, match_value, reason}} ->
|
||||||
Logger.error("Failed to apply #{type} rule", %{
|
Logger.error(fn ->
|
||||||
match_value: match_value,
|
"failed to apply #{type} rule " <>
|
||||||
error: reason
|
"with match #{match_value} " <>
|
||||||
})
|
"with reason #{inspect(reason)}"
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user