- Defining a global const DEBUG in its own file.
DEBUG = true
- importing (requiring) it in all concerned code files.
- printing conditionally:
if DEBUG
puts "Oops!"
end
DEBUG = true
if DEBUG
puts "Oops!"
end
Use log module.
require "log"
Log.setup(:debug)
Log.debug {"Oops!"}
Perfect. Thank you!
Also, you can try GitHub - Sija/debug.cr: Debug macro for Crystal
That’s beautiful!!