Add a 'debug' mode, controls whether or not logging is enabled

We could serve a nop function instead with debug disabled to avoid the check at runtime.