anchor.diff:      process_flag(trap_exit, true),
       case file:open(File, [write]) of
   	{ok,Fd} ->
  -	    {ok, {Fd, File, PrevHandler}};
  +	    {ok, #st{fd=Fd,filename=File,prev_handler=PrevHandler}};
   	Error ->
   	    Error
       end.
       
   handle_event({_Type, GL, _Msg}, State) when node(GL) =/= node() ->
       {ok, State};
  -handle_event(Event, {Fd, File, PrevHandler}) ->
  -    write_event(Fd, tag_event(Event)),
  -    {ok, {Fd, File, PrevHandler}};
  -handle_event(_, State) ->
  +handle_event(Event, State) ->
  +    write_event(State, Event),
       {ok, State}.
   
  -handle_info({'EXIT', Fd, _Reason}, {Fd, _File, PrevHandler}) ->
  +handle_info({'EXIT', Fd, _Reason}, #st{fd=Fd,prev_handler=PrevHandler}) ->
       case PrevHandler of
   	[] ->
   	    remove_handler;
  
positive.code: 	 handle_event/2, handle_call/2, handle_info/2,
  	 terminate/2, code_change/3]).
  
  %% This one is used when we takeover from the simple error_logger.
  init({File, {error_logger, Buf}}) ->
      case init(File, error_logger) of
  	{ok, {Fd, File, PrevHandler}} ->
  	    write_events(Fd, Buf),
  	    {ok, {Fd, File, PrevHandler}};
  	Error ->
  	    Error
      end;
  
negative.code: %%% Misc. functions.
  %%% ------------------------------------------------------
  
  write_events(State, [Ev|Es]) ->
      %% Write the events in reversed order.
      write_events(State, Es),
      write_event(State, Ev);
  write_events(_State, []) ->
      ok.
  
  write_event(#st{fd=Fd}=State, Event) ->
      case parse_event(Event) of
  	ignore ->
  	    ok;
  	{Head,Pid,FormatList} ->
  	    Time = maybe_utc(erlang:universaltime()),
  	    Header = write_time(Time, Head),
  	    Body = format_body(State, FormatList),
  	    AtNode = if
  			 node(Pid) =/= node() ->
  			     ["** at node ",atom_to_list(node(Pid))," **\n"];
  			 true ->
  			     []
  		     end,
  	    io:put_chars(Fd, [Header,Body,AtNode])
      end.
  
  format_body(State, [{Format,Args}|T]) ->
      S = try io_lib:format(Format, Args) of
  	    S0 ->
  		S0
  	catch
  	    _:_ ->
  		io_lib:format("ERROR: ~p - ~p\n", [Format,Args])
  	end,
      [S|format_body(State, T)];
  format_body(_State, []) ->
      [].
  
  parse_event({error, _GL, {Pid, Format, Args}}) ->
      {"ERROR REPORT",Pid,[{Format,Args}]};
  parse_event({info_msg, _GL, {Pid, Format, Args}}) ->
      {"INFO REPORT",Pid,[{Format, Args}]};
  parse_event({warning_msg, _GL, {Pid, Format, Args}}) ->
      {"WARNING REPORT",Pid,[{Format,Args}]};
  parse_event({error_report, _GL, {Pid, std_error, Args}}) ->
      {"ERROR REPORT",Pid,format_term(Args)};
  parse_event({info_report, _GL, {Pid, std_info, Args}}) ->
      {"INFO REPORT",Pid,format_term(Args)};
  parse_event({warning_report, _GL, {Pid, std_warning, Args}}) ->
      {"WARNING REPORT",Pid,format_term(Args)};
  parse_event(_) -> ignore.
  
  maybe_utc(Time) ->
      UTC = case application:get_env(sasl, utc_log) of
  