Skip to content

Commit

Permalink
Delegate activity logging from main ActivityLog context to ActivityLo…
Browse files Browse the repository at this point in the history
…gger
  • Loading branch information
nelsonkopliku committed Jul 1, 2024
1 parent 9630194 commit f0105fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/trento/activity_log.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ defmodule Trento.ActivityLog do
end
end

@spec log_activity(any()) :: :ok
defdelegate log_activity(activity), to: Trento.ActivityLog.ActivityLogger

defp log_error({:error, _} = error, message) do
Logger.error("#{message}: #{inspect(error)}")
error
Expand Down
4 changes: 2 additions & 2 deletions lib/trento/activity_logging/activity_logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ defmodule Trento.ActivityLog.ActivityLogger do
ActivityLogger entry point
"""

@callback log_activity(context :: any()) :: :ok
@callback log_activity(activity :: any()) :: :ok

def log_activity(context), do: adapter().log_activity(context)
def log_activity(activity), do: adapter().log_activity(activity)

defp adapter, do: Application.fetch_env!(:trento, __MODULE__)[:adapter]
end

0 comments on commit f0105fb

Please sign in to comment.