anchor.diff:  log(Level, Pid, Format, Args) ->
       Timestamp = lager_util:format_time(),
       Msg = [["[", atom_to_list(Level), "] "], io_lib:format("~p ", [Pid]),
  -        string_reduce(lager_trunc_io:format(Format, Args, 4096))],
  +           format_string_chop(Format, Args, 4096)],
       safe_notify(lager_util:level_to_num(Level), Timestamp, Msg).
   
   %% @doc Set the loglevel for a particular backend.
  
positive.code: log(Level, Module, Function, Line, Pid, Time, Format, Args) ->
      Timestamp = lager_util:format_time(Time),
      Msg = [["[", atom_to_list(Level), "] "],
          io_lib:format("~p@~p:~p:~p ", [Pid, Module, Function, Line]),
          string_reduce(lager_trunc_io:format(Format, Args, 4096))],
      safe_notify(lager_util:level_to_num(Level), Timestamp, Msg).
  
  %% @doc Manually log a message into lager without using the parse transform.
  
negative.code:             gen_event:sync_notify(Pid, {log, Level, Timestamp, Msg})
      end.
  
  %% @doc Print the format string `Fmt' with `Args' safely with a size
  %% limit of `Limit'. If the format string is invalid, or not enough
  %% arguments are supplied 'FORMAT ERROR' is printed with the offending
  %% arguments. The caller is NOT crashed.
  
  safe_format(Fmt, Args, Limit) ->
      try lager_trunc_io:format(Fmt, Args, Limit) of
          Result -> Result
      catch
          _:_ -> lager_trunc_io:format("FORMAT ERROR: ~p ~p", [Fmt, Args], Limit)
      end.
  
  %% @private
  format_string_chop(Fmt, Args, Limit) ->
      re:replace(safe_format(Fmt, Args, Limit), "\n$", "", [{return, list}]).
  