Type system debug bool to elide code based on function parameter

I’m sure there is a known idiom for this, but I can’t find it at the moment.

I want to write something like:

function run(a, b, debugBool)
  # ... do lots of stuff
  debugBool && @show debug info
  # ... do lots of stuff
end

I want the compiler to compile two versions of the function: one for debugBool=true and one for debugBool=false, and have the compiler smart enough to leave out the debug code when the parameter is false. It seems like some sort of Val{Bool} type would do this, but I’m not sure how to get it right in the signature and call site, and how to make sure the conditional is done in such a way that the compiler will know it can ignore that code in the false case.

The function is rather long, so duplicating the code is not desirable. Also, during the same run, I’ll call both the debug and non-debug versions, so a global enable/disable debug macro wouldn’t work.