macro Util.lgi(): log names (expressions) and values
This commit is contained in:
parent
5123c1b3e8
commit
88d6544749
4 changed files with 11 additions and 2 deletions
|
|
@ -58,7 +58,7 @@ defmodule Scopes.CSys do
|
|||
# send shortcuts
|
||||
|
||||
def send_message(rcvr, head, data \\ %{}) do
|
||||
Logger.info rcvr: inspect(rcvr), head: inspect(head), data: inspect(data)
|
||||
Logger.debug rcvr: inspect(rcvr), head: inspect(head), data: inspect(data)
|
||||
Actor.send(rcvr, Shape.create(head, data: data))
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ defmodule Scopes.CSys.Program do
|
|||
limit = args[:limit]
|
||||
data = Shape.data(msg)
|
||||
state = CSys.state(scope)
|
||||
Logger.info data: data, state_value: state.value, threshold: threshold, self: self()
|
||||
Logger.debug data: data, state_value: state.value, threshold: threshold, self: self()
|
||||
value_n = state.value + data.value
|
||||
if value_n >= threshold do
|
||||
value_out = limit && rem(value_n - 1, limit) + limit || value_n
|
||||
|
|
|
|||
|
|
@ -6,4 +6,12 @@ defmodule Scopes.Util do
|
|||
Enum.zip(names, fields) |> Map.new
|
||||
end
|
||||
end
|
||||
|
||||
defmacro lgi(fields) do
|
||||
#IO.inspect(fields)
|
||||
quote do
|
||||
require Logger
|
||||
Logger.info(Scopes.Util.fields_info(unquote(fields)))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ defmodule Scopes.UtilTest do
|
|||
test "fields" do
|
||||
{a, b, c} = {17, 22, 42}
|
||||
assert %{"a" => 17, "b" => 22, "c" => 42} = Util.fields_info([a, b, c])
|
||||
Util.lgi([a, b, c])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue