this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix SimLogger when message has no variables

garrison 52391a64 5e0ad5d4

+15 -8
+13 -8
lib/trinity/sim_logger.ex
··· 55 55 defmacro debug(message) do 56 56 key = simulation_key() 57 57 58 - {:<<>>, _, elements} = message 59 58 values = 60 - Enum.reduce(elements, [], fn 61 - {:"::", _, [{{:., _, [Kernel, :to_string]}, _, [value]}, {:binary, _, _}]}, acc -> 62 - [value | acc] 63 - _, acc -> 64 - acc 65 - end) 66 - |> Enum.reverse() 59 + case message do 60 + {:<<>>, _, elements} -> 61 + # Extract interpolated variables 62 + Enum.reduce(elements, [], fn 63 + {:"::", _, [{{:., _, [Kernel, :to_string]}, _, [value]}, {:binary, _, _}]}, acc -> [value | acc] 64 + _, acc -> acc 65 + end) 66 + |> Enum.reverse() 67 + 68 + string when is_binary(string) -> 69 + # There are no interpolated variables 70 + [] 71 + end 67 72 68 73 %{module: module, line: line} = __CALLER__ 69 74 values_tuple = {:{}, [], [module, line | values]}
+2
test/trinity_test.exs
··· 34 34 } 35 35 state = write_value(state, initial_count) 36 36 37 + # Note: this intentionally tests a log message with no variables 38 + SimLogger.debug "Init complete" 37 39 {:ok, state} 38 40 end 39 41