I made a dead simple Console class in AS3 that allows logging to be turned on or off with a boolean switch on the class. When the boolean is set to false, all the calls to Console.log("message") do nothing instead of trace("message").
(I know there are frameworks available for AS3 logging – this was a quick, lightweight fix for me in this context.)
It saves me having to comment out or remove the multitude of Console messages before going to production, but means there are hundreds or thousands of calls to an empty function happening when this runs.
I haven’t seen any problems yet with this approach – the performance hit seems to be negligible – but am I missing anything? Are there any gotchas to be aware of when calling empty functions over and over again?
If the performance isn’t suffering there’s nothing wrong with that. I similarly use NullLoggers which have empty methods for logging. See Null Object Pattern