anchor.diff:  
   set_group_leader() ->
       case whereis(user) of
  -	User when is_pid(User) -> link(User), group_leader(User,self()), User;
  -	_                      -> false
  +	User when is_pid(User) ->
  +	    link(User),
  +	    group_leader(User,self()),
  +	    User;
  +	_ ->
  +	    false
       end.
   
   tag_event(Event) ->    
       {erlang:universaltime(), Event}.
   
  -%% IOMOd is always 'io'
  -write_events(Events,IOMod) -> write_events1(lists:reverse(Events),IOMod).
  -
  -write_events1([Event|Es],IOMod) ->
  -    ok = write_event(Event,IOMod),
  -    write_events1(Es,IOMod);
  -write_events1([],_IOMod) ->
  +write_events(State, [Ev|Es]) ->
  +    %% Write the events in reverse order.
  +    _ = write_events(State, Es),
  +    _ = do_write_event(State, Ev),
  +    ok;
  +write_events(_State, []) ->
       ok.
   
  -write_event({Time, {error, _GL, {Pid, Format, Args}}},IOMod) ->
  -    T = write_time(maybe_utc(Time)),
  -    case catch io_lib:format(add_node(Format,Pid), Args) of
  -	S when is_list(S) ->
  -	    format(IOMod, T ++ S);
  -	_ ->
  -	    F = add_node("ERROR: ~p - ~p~n", Pid),
  -	    format(IOMod, T ++ F, [Format,Args])
  -    end;
  -write_event({Time, {error_report, _GL, {Pid, std_error, Rep}}},IOMod) ->
  -    T = write_time(maybe_utc(Time)),
  -    S = format_report(Rep),
  -    format(IOMod, T ++ S ++ add_node("", Pid));
  -write_event({Time, {info_report, _GL, {Pid, std_info, Rep}}},IOMod) ->
  -    T = write_time(maybe_utc(Time), "INFO REPORT"),
  -    S = format_report(Rep),
  -    format(IOMod, T ++ S ++ add_node("", Pid));
  -write_event({Time, {info_msg, _GL, {Pid, Format, Args}}},IOMod) ->
  -    T = write_time(maybe_utc(Time), "INFO REPORT"),
  -    case catch io_lib:format(add_node(Format,Pid), Args) of
  -	S when is_list(S) ->
  -	    format(IOMod, T ++ S);
  -	_ ->
  -	    F = add_node("ERROR: ~p - ~p~n", Pid),
  -	    format(IOMod, T ++ F, [Format,Args])
  -    end;
  -write_event({Time, {warning_report, _GL, {Pid, std_warning, Rep}}},IOMod) ->
  -    T = write_time(maybe_utc(Time), "WARNING REPORT"),
  -    S = format_report(Rep),
  -    format(IOMod, T ++ S ++ add_node("", Pid));
  -write_event({Time, {warning_msg, _GL, {Pid, Format, Args}}},IOMod) ->
  -    T = write_time(maybe_utc(Time), "WARNING REPORT"),
  -    case catch io_lib:format(add_node(Format,Pid), Args) of
  -	S when is_list(S) ->
  -	    format(IOMod, T ++ S);
  -	_ ->
  -	    F = add_node("ERROR: ~p - ~p~n", Pid),
  -	    format(IOMod, T ++ F, [Format,Args])
  -    end;
  -write_event({_Time, _Error},_IOMod) ->
  +do_write_event(State, {Time0, Event}) ->
  +    case parse_event(Event) of
  +	ignore ->
  +	    ok;
  +	{Head,Pid,FormatList} ->
  +	    Time = maybe_utc(Time0),
  +	    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,
  +	    Str = [Header,Body,AtNode],
  +	    case State#st.io_mod of
  +		io_lib ->
  +		    Str;
  +		io ->
  +		    io:put_chars(user, Str)
  +	    end
  +    end;
  +do_write_event(_, _) ->
       ok.
  +
  +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
  
positive.code: 
  handle_call(_Query, State) -> {ok, {error, bad_query}, State}.
  
  % unfortunately, we can't unlink from User - links are not counted!
  %    if pid(User) -> unlink(User); true -> ok end,
  terminate(install_prev, _State) ->
      [];
  terminate(_Reason, {_User, PrevHandler}) ->
      {error_logger_tty_h, PrevHandler}.
  
  code_change(_OldVsn, State, _Extra) ->
      {ok, State}.
  
  %%% ------------------------------------------------------
  %%% Misc. functions.
  
negative.code: maybe_utc(Time, true) -> {utc, Time};
  maybe_utc(Time, _) -> {local, calendar:universal_time_to_local_time(Time)}.
  
  format_term(Term) when is_list(Term) ->
      case string_p(Term) of
  	true ->
  	    [{"~s\n",[Term]}];
  	false ->
  	    format_term_list(Term)
      end;
  format_term(Term) ->
      [{"~p\n",[Term]}].
  
  format_term_list([{Tag,Data}|T]) ->
      [{"    ~p: ~p\n",[Tag,Data]}|format_term_list(T)];
  format_term_list([Data|T]) ->
      [{"    ~p\n",[Data]}|format_term_list(T)];
  format_term_list([]) ->
      [];
  format_term_list(_) ->
      %% Continue to allow non-proper lists for now.
      %% FIXME: Remove this clause in OTP 19.
      [].
  
  string_p([]) ->
      false;
  