diff --git a/lib/csys/csys.ex b/lib/csys/csys.ex index f52e254..b8fdf66 100644 --- a/lib/csys/csys.ex +++ b/lib/csys/csys.ex @@ -1,11 +1,13 @@ defmodule Scopes.CSys do require Logger + require Scopes.Util alias Scopes.Core.Actor alias Scopes.Shape + alias Scopes.Util def neuron(scope) do - #Logger.info([scope: inspect(scope)]) + #Logger.info(Util.show [scope]) Actor.create(fn msg -> process(msg, scope) end) end @@ -58,7 +60,7 @@ defmodule Scopes.CSys do # send shortcuts def send_message(rcvr, head, data \\ %{}) do - Logger.debug rcvr: inspect(rcvr), head: inspect(head), data: inspect(data) + Logger.debug(Util.show [rcvr, head, data]) Actor.send(rcvr, Shape.create(head, data: data)) end diff --git a/lib/csys/program.ex b/lib/csys/program.ex index f589298..88a6d9c 100644 --- a/lib/csys/program.ex +++ b/lib/csys/program.ex @@ -1,9 +1,11 @@ defmodule Scopes.CSys.Program do require Logger + require Scopes.Util alias Scopes.CSys alias Scopes.CSys.Environ alias Scopes.Shape + alias Scopes.Util defmodule State do defstruct [:value, :count, :stage, :prog] @@ -74,7 +76,7 @@ defmodule Scopes.CSys.Program do limit = args[:limit] data = Shape.data(msg) state = CSys.state(scope) - Logger.debug data: data, state_value: state.value, threshold: threshold, self: self() + Logger.debug(Util.show [data, state.value, threshold, self()]) value_n = state.value + data.value if value_n >= threshold do value_out = limit && rem(value_n - 1, limit) + limit || value_n diff --git a/lib/util.ex b/lib/util.ex index a103e62..a21a1a9 100644 --- a/lib/util.ex +++ b/lib/util.ex @@ -1,17 +1,8 @@ defmodule Scopes.Util do - - defmacro fields_info(fields) do + defmacro show(fields) do names = for f <- fields do Macro.to_string(f) end quote bind_quoted: [names: names, fields: fields] 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 diff --git a/test/util_test.exs b/test/util_test.exs index 5a1c5d4..07eb9b2 100644 --- a/test/util_test.exs +++ b/test/util_test.exs @@ -7,8 +7,7 @@ defmodule Scopes.UtilTest do describe "info:" 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]) + assert %{"a" => 17, "b" => 22, "c" => 42} = Util.show([a, b, c]) end end end