I am not sure I understand what you are trying to do here, but if you want to print 20 variables and 20 distinct messages, how could the code be any easier to read? You have to specify this information somehow.
The idea was to have the 20 variables (actually less in real) in the block (e.g. info or debug).
When passing all variable as parameter in the line of code soon becomes difficult to read.
If the variables could 1 per line than it would be, in my opinion, easier to handle
macro myinfo(msg, block)
block isa Expr && block.head == :block || error("Usage: @myinfo <msg> <block-with-variables>")
variables = filter(x -> !(x isa LineNumberNode), block.args)
esc(quote
@info $msg $(variables...)
end)
end
How it works:
julia> a = 1; b = "hello"; c = rand();
julia> @myinfo "great stuffs" begin
a
b
c
end
┌ Info: great stuffs
│ a = 1
│ b = "hello"
└ c = 0.4109823300537361