Skip to content

Commit

Permalink
simply wrapping the Logger call in a function is good enough
Browse files Browse the repository at this point in the history
  • Loading branch information
hazardfn committed Jul 16, 2020
1 parent 4aee63d commit d9237aa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/swarm/tracker/tracker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -111,31 +111,31 @@ defmodule Swarm.Tracker do
{current_state, _arity} = __CALLER__.function

quote do
Logger.debug(Swarm.Logger.format("[tracker:#{unquote(current_state)}] #{unquote(msg)}"))
Logger.debug(fn -> Swarm.Logger.format("[tracker:#{unquote(current_state)}] #{unquote(msg)}") end)
end
end

defmacrop info(msg) do
{current_state, _arity} = __CALLER__.function

quote do
Logger.info(Swarm.Logger.format("[tracker:#{unquote(current_state)}] #{unquote(msg)}"))
Logger.info(fn -> Swarm.Logger.format("[tracker:#{unquote(current_state)}] #{unquote(msg)}") end)
end
end

defmacrop warn(msg) do
{current_state, _arity} = __CALLER__.function

quote do
Logger.warn(Swarm.Logger.format("[tracker:#{unquote(current_state)}] #{unquote(msg)}"))
Logger.warn(fn -> Swarm.Logger.format("[tracker:#{unquote(current_state)}] #{unquote(msg)}") end)
end
end

defmacrop error(msg) do
{current_state, _arity} = __CALLER__.function

quote do
Logger.error(Swarm.Logger.format("[tracker:#{unquote(current_state)}] #{unquote(msg)}"))
Logger.error(fn -> Swarm.Logger.format("[tracker:#{unquote(current_state)}] #{unquote(msg)}") end)
end
end

Expand Down

0 comments on commit d9237aa

Please sign in to comment.