Print debugging statement: Difference between revisions

julia example
(add Mercury)
(julia example)
Line 118:
value: &main.point{x:2, y:3}
</pre>
 
 
=={{header|Julia}}==
Julia has a built-n Logging system, and there are several modules, such as Memento, with extended logging abilities. There are defined levels of error, warn, info, and debug. By default, debug level statements in code are not printed unless the logging level is set to allow debug statements to print, which can be enabled by setting the JULIA_DEBUG environment variable.
<lang julia>function test()
@info "starting test()"
a = [1, 2]
for i in 1:4
if i > 3
@debug "debugging $a at line $(@__LINE__) of file $(@__FILE__)"
else
a .*= 2
end
end
@warn "exiting test()"
println()
end
 
test()
 
ENV["JULIA_DEBUG"] = "all"
 
test()
</lang>{{out}}
<pre>
[ Info: starting test()
┌ Warning: exiting test()
└ @ Main C:\Users\William\Documents\Julia Scripts\test2.jl:13
 
[ Info: starting test()
┌ Debug: debugging [8, 16] at line 8 of file C:\Users\William\Documents\Julia Scripts\test2.jl
└ @ Main C:\Users\William\Documents\Julia Scripts\test2.jl:8
┌ Warning: exiting test()
└ @ Main C:\Users\William\Documents\Julia Scripts\test2.jl:13
</pre>
 
 
=={{header|Mercury}}==
4,105

edits