Use debug.getinfo to see if your replacement print function is being called from the first function on the call stack (the interpreter). It would look like:
if debug.getinfo(3) == nil then -- interpreter else -- normal end