Avoid formatting message when not logging

The formatting function is called even  when there is no log function
provided. It can have a noticeable performance impact in IE7. The log
function now has a flag 'noop' set to true when there is no user-defined
log function.