As mentioned earlier, this logging manipulation would be better handled as an exception.  If you want to produce the detailed log in the result page, then change export_to_git to accept a logger to use.  Monkey-patching like this is not thread-safe, in addition to being difficult to understand.