Have you ever had, at least once, an exception when logging an exception because you’d screwed up the number of logging arguments?
Something akin to the following:
>>> import logging >>> msg1, msg2 = 'Look', 'leap!' >>> try: ... 1 / 0 ... except Exception: ... # crash and burn - no msg2. where is my unit test?!!! ... logging.exception('%s before you %s', msg1) ... Traceback (most recent call last): ... TypeError: not enough arguments for format string
Here is what you get in Erlang:
1> error_logger:info_msg("~s before you ~s~n", ["Look"]). ok =INFO REPORT==== 22-Jun-2011::23:09:49 === ERROR: "~s before you ~s~n" - ["Look"] 2>
That’s right – you get ‘ok’ and a report. That allows you to get critical information even if there is a problem with your log message arguments without blowing your whole system. I like that, makes the system more fault-tolerant.