I worked on a codebase that had a special logging function with a name like NoPushLog that was just a direct wrapper of the base log function. A githook checked that this string was not in pushed code.
This solves many of the concerns raised in this thread about readability, automation, avoiding typos in the magic string.
The tricky thing you have to solve is how to push the code that defines the custom logging function, but there are solutions.