I don't think there's a standard way. The thing that seems most natural to me would be defining a @log macro like:
macro log(s)
quote
if logging
print($s)
end
end
end
This inserts a global variable called logging everywhere, but there should be solutions for that problem.
-- John
On Sep 10, 2013, at 6:18 PM, Aditya Mahajan <
adi.m...@gmail.com> wrote:
> Hi,
>
> What is the standard method of printing logging info in Julia?
>
> I have an iterative algorithm, say iteration(initial), and I want to invoke it in two ways:
>
> 1. iteration(initial; logging=true) which should print the value of some internal variable onto the screen,
>
> 2. iteration(initial; logging=false) which should not display this diagnostic information.
>
> Of course, I can use
>
> if logging
> @print("....")
> end
>
> inside the function, but that seems like a kludge. Is there a standard way of writing such logging functions in Julia.
>
> Thanks,
> Aditya
>