From 3ca14ef7eab62f51ddacc8b22c19f3a7c8b96367 Mon Sep 17 00:00:00 2001 From: Uwe Dauernheim Date: Fri, 6 Jan 2012 19:18:05 +0100 Subject: [PATCH] Redirect output to stderr where appropriate --- lib/asn1/src/asn1ct.erl | 20 ++++++----- lib/asn1/src/asn1ct_check.erl | 34 +++++++++++-------- lib/asn1/src/asn1ct_gen.erl | 2 +- lib/asn1/src/asn1ct_tok.erl | 5 +-- lib/common_test/src/ct_framework.erl | 6 ++-- lib/common_test/src/ct_logs.erl | 41 +++++++++++++---------- lib/common_test/src/ct_make.erl | 6 ++-- lib/common_test/src/ct_master.erl | 20 +++++++---- lib/common_test/src/ct_repeat.erl | 12 ++++--- lib/common_test/src/ct_run.erl | 27 +++++++++------ lib/common_test/src/ct_telnet_client.erl | 2 +- lib/common_test/src/ct_util.erl | 4 +-- lib/common_test/src/vts.erl | 4 +-- lib/compiler/src/beam_clean.erl | 3 +- lib/compiler/src/beam_validator.erl | 2 +- lib/compiler/src/compile.erl | 12 +++---- lib/compiler/src/sys_pre_attributes.erl | 4 +-- lib/dialyzer/src/dialyzer.erl | 2 +- lib/edoc/src/edoc.erl | 4 +-- lib/edoc/src/edoc_report.erl | 27 ++++++++++++--- lib/eunit/src/eunit_server.erl | 5 +-- lib/eunit/src/eunit_tty.erl | 16 ++++----- lib/hipe/cerl/cerl_cconv.erl | 2 +- lib/hipe/icode/hipe_icode_type.erl | 6 ++-- lib/ic/src/ic.erl | 10 +++--- lib/ic/src/ic_error.erl | 10 +++--- lib/ic/src/ic_jbe.erl | 3 +- lib/ic/src/ic_pp.erl | 12 +++---- lib/ic/src/ic_pragma.erl | 34 +++++++++---------- lib/ic/src/icstruct.erl | 3 +- lib/ic/src/ictype.erl | 2 +- lib/parsetools/src/leex.erl | 8 ++--- lib/parsetools/src/yecc.erl | 13 +++---- lib/parsetools/src/yeccscan.erl | 3 +- lib/reltool/src/reltool.erl | 3 +- lib/reltool/src/reltool_sys_win.erl | 11 +++--- lib/sasl/src/systools.erl | 4 +-- lib/sasl/src/systools_make.erl | 8 ++--- lib/sasl/src/systools_relup.erl | 8 ++--- lib/snmp/src/agent/snmpa_error_io.erl | 2 +- lib/snmp/src/compile/snmpc.erl | 2 +- lib/snmp/src/compile/snmpc_lib.erl | 13 +++---- lib/snmp/src/compile/snmpc_mib_to_hrl.erl | 2 +- lib/stdlib/src/c.erl | 21 +++++++----- lib/stdlib/src/epp.erl | 2 +- lib/stdlib/src/erl_compile.erl | 19 ++++++----- lib/stdlib/src/escript.erl | 22 ++++++------ lib/stdlib/src/shell.erl | 7 +++- lib/test_server/src/test_server.erl | 33 +++++++++++------- lib/test_server/src/test_server_ctrl.erl | 28 +++++++++------- lib/test_server/src/ts_reports.erl | 14 ++++---- lib/test_server/src/ts_run.erl | 8 ++--- lib/tools/src/cover.erl | 10 +++--- lib/tools/src/make.erl | 6 ++-- lib/tools/src/xref_base.erl | 11 +++--- 55 files changed, 344 insertions(+), 254 deletions(-) diff --git a/lib/asn1/src/asn1ct.erl b/lib/asn1/src/asn1ct.erl index 85bb5b2f28c4..0ce51e72848c 100644 --- a/lib/asn1/src/asn1ct.erl +++ b/lib/asn1/src/asn1ct.erl @@ -87,7 +87,9 @@ compile(File) -> compile(File,Options) when is_list(Options) -> case lists:member(driver, Options) of %% remove me in R16A! true -> - io:format("Warning: driver option is obsolete and will be removed in R16A, use nif instead!"); + io:format(standard_error, + "Warning: driver option is obsolete " + "and will be removed in R16A, use nif instead!"); false -> ok end, @@ -1460,18 +1462,18 @@ vsn() -> print_error_message([got,H|T]) when is_list(H) -> - io:format(" got:"), + io:format(standard_error, " got:"), print_listing(H,"and"), print_error_message(T); print_error_message([expected,H|T]) when is_list(H) -> - io:format(" expected one of:"), + io:format(standard_error, " expected one of:"), print_listing(H,"or"), print_error_message(T); print_error_message([H|T]) -> - io:format(" ~p",[H]), + io:format(standard_error, " ~p",[H]), print_error_message(T); print_error_message([]) -> - io:format("~n"). + io:format(standard_error, "~n"). print_listing([H1,H2|[]],AndOr) -> io:format(" ~p ~s ~p",[H1,AndOr,H2]); @@ -2544,7 +2546,7 @@ type_check(#'Externaltypereference'{}) -> error(Format, Args, S) -> case is_error(S) of true -> - io:format(Format, Args); + io:format(standard_error, Format, Args); false -> ok end. @@ -2552,7 +2554,7 @@ error(Format, Args, S) -> warning(Format, Args, S) -> case is_warning(S) of true -> - io:format("Warning: " ++ Format, Args); + io:format(standard_error, "Warning: " ++ Format, Args); false -> ok end. @@ -2560,10 +2562,10 @@ warning(Format, Args, S) -> warning(Format, Args, S, Reason) -> case {is_werr(S), is_error(S), is_warning(S)} of {true, true, _} -> - io:format(Format, Args), + io:format(standard_error, Format, Args), throw({error, Reason}); {false, _, true} -> - io:format(Format, Args); + io:format(standard_error, Format, Args); _ -> ok end. diff --git a/lib/asn1/src/asn1ct_check.erl b/lib/asn1/src/asn1ct_check.erl index e31847723472..0c695afdf689 100644 --- a/lib/asn1/src/asn1ct_check.erl +++ b/lib/asn1/src/asn1ct_check.erl @@ -4241,7 +4241,7 @@ check_constraint(S,{simpletable,Type}) -> ObjSet = GetObjectSet(TorVDef), {simpletable,check_object(S,Type,ObjSet)}; #'ObjectSet'{} -> - io:format("ALERT: simpletable forbidden case!~n",[]), + io:format(standard_error, "ALERT: simpletable forbidden case!~n",[]), {simpletable,check_object(S,Type,C)}; {'ValueFromObject',{_,ORef},FieldName} -> %% This is an ObjectFromObject @@ -7153,7 +7153,7 @@ findtypes_and_values([],Tacc,Vacc,Pacc,Cacc,Oacc,OSacc) -> error({export,Msg,#state{mname=Mname,type=Ref,tname=Typename}}) -> Pos = Ref#'Externaltypereference'.pos, - io:format("asn1error:~p:~p:~p~n~p~n",[Pos,Mname,Typename,Msg]), + io:format(standard_error, "asn1error:~p:~p:~p~n~p~n",[Pos,Mname,Typename,Msg]), {error,{export,Pos,Mname,Typename,Msg}}; error({import,Msg,#state{mname=Mname,type=Ref,tname=Typename}}) -> PosOfDef = @@ -7161,52 +7161,58 @@ error({import,Msg,#state{mname=Mname,type=Ref,tname=Typename}}) -> (#'Externalvaluereference'{pos=P}) -> P end, Pos = PosOfDef(Ref), - io:format("asn1error:~p:~p:~p~n~p~n",[Pos,Mname,Typename,Msg]), + io:format(standard_error, "asn1error:~p:~p:~p~n~p~n",[Pos,Mname,Typename,Msg]), {error,{import,Pos,Mname,Typename,Msg}}; % error({type,{Msg1,Msg2},#state{mname=Mname,type=Type,tname=Typename}}) % when is_record(Type,typedef) -> -% io:format("asn1error:~p:~p:~p ~p~n", +% io:format(standard_error, "asn1error:~p:~p:~p ~p~n", % [Type#typedef.pos,Mname,Typename,Msg1]), % {error,{type,Type#typedef.pos,Mname,Typename,Msg1,Msg2}}; error({type,Msg,#state{mname=Mname,type=Type,tname=Typename}}) when is_record(Type,type) -> - io:format("asn1error:~p:~p~n~p~n", + io:format(standard_error, "asn1error:~p:~p~n~p~n", [Mname,Typename,Msg]), {error,{type,Mname,Typename,Msg}}; error({type,Msg,#state{mname=Mname,type=Type,tname=Typename}}) when is_record(Type,typedef) -> - io:format("asn1error:~p:~p:~p~n~p~n", + io:format(standard_error, "asn1error:~p:~p:~p~n~p~n", [Type#typedef.pos,Mname,Typename,Msg]), {error,{type,Type#typedef.pos,Mname,Typename,Msg}}; error({type,Msg,#state{mname=Mname,type=Type,tname=Typename}}) when is_record(Type,ptypedef) -> - io:format("asn1error:~p:~p:~p~n~p~n", + io:format(standard_error, "asn1error:~p:~p:~p~n~p~n", [Type#ptypedef.pos,Mname,Typename,Msg]), {error,{type,Type#ptypedef.pos,Mname,Typename,Msg}}; error({type,Msg,#state{mname=Mname,value=Value,vname=Valuename}}) when is_record(Value,valuedef) -> - io:format("asn1error:~p:~p:~p~n~p~n",[Value#valuedef.pos,Mname,Valuename,Msg]), + io:format(standard_error,"asn1error:~p:~p:~p~n~p~n", + [Value#valuedef.pos,Mname,Valuename,Msg]), {error,{type,Value#valuedef.pos,Mname,Valuename,Msg}}; error({type,Msg,#state{mname=Mname,type=Type,tname=Typename}}) when is_record(Type,pobjectdef) -> - io:format("asn1error:~p:~p:~p~n~p~n", + io:format(standard_error, "asn1error:~p:~p:~p~n~p~n", [Type#pobjectdef.pos,Mname,Typename,Msg]), {error,{type,Type#pobjectdef.pos,Mname,Typename,Msg}}; error({value,Msg,#state{mname=Mname,value=Value,vname=Valuename}}) when is_record(Value,valuedef) -> - io:format("asn1error:~p:~p:~p~n~p~n",[Value#valuedef.pos,Mname,Valuename,Msg]), + io:format(standard_error, "asn1error:~p:~p:~p~n~p~n", + [Value#valuedef.pos,Mname,Valuename,Msg]), {error,{value,Value#valuedef.pos,Mname,Valuename,Msg}}; error({Other,Msg,#state{mname=Mname,value=#valuedef{pos=Pos},vname=Valuename}}) -> - io:format("asn1error:~p:~p:~p~n~p~n",[Pos,Mname,Valuename,Msg]), + io:format(standard_error, "asn1error:~p:~p:~p~n~p~n", + [Pos,Mname,Valuename,Msg]), {error,{Other,Pos,Mname,Valuename,Msg}}; error({Other,Msg,#state{mname=Mname,type=#typedef{pos=Pos},tname=Typename}}) -> - io:format("asn1error:~p:~p:~p~n~p~n",[Pos,Mname,Typename,Msg]), + io:format(standard_error, "asn1error:~p:~p:~p~n~p~n", + [Pos,Mname,Typename,Msg]), {error,{Other,Pos,Mname,Typename,Msg}}; error({Other,Msg,#state{mname=Mname,type=#classdef{pos=Pos},tname=Typename}}) -> - io:format("asn1error:~p:~p:~p~n~p~n",[Pos,Mname,Typename,Msg]), + io:format(standard_error, "asn1error:~p:~p:~p~n~p~n", + [Pos,Mname,Typename,Msg]), {error,{Other,Pos,Mname,Typename,Msg}}; error({Other,Msg,#state{mname=Mname,type=Type,tname=Typename}}) -> - io:format("asn1error:~p:~p:~p~n~p~n",[asn1ct:get_pos_of_def(Type),Mname,Typename,Msg]), + io:format(standard_error, "asn1error:~p:~p:~p~n~p~n", + [asn1ct:get_pos_of_def(Type),Mname,Typename,Msg]), {error,{Other,asn1ct:get_pos_of_def(Type),Mname,Typename,Msg}}. include_default_type(Module) -> diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl index 0f8833f71673..c5d47a24fc58 100644 --- a/lib/asn1/src/asn1ct_gen.erl +++ b/lib/asn1/src/asn1ct_gen.erl @@ -1308,7 +1308,7 @@ fopen(F, ModeList) -> {ok, Fd} -> Fd; {error, Reason} -> - io:format("** Can't open file ~p ~n", [F]), + io:format(standard_error, "** Can't open file ~p ~n", [F]), exit({error,Reason}) end. diff --git a/lib/asn1/src/asn1ct_tok.erl b/lib/asn1/src/asn1ct_tok.erl index 85199c65ecff..adbfcbcfeb81 100644 --- a/lib/asn1/src/asn1ct_tok.erl +++ b/lib/asn1/src/asn1ct_tok.erl @@ -44,7 +44,8 @@ process(L, Stream,Lno,R) when is_list(L) -> %%io:format('read:~s',[L]), case catch tokenise(Stream,L,Lno,[]) of {'ERR',Reason} -> - io:format("Tokeniser error on line: ~w ~w~n",[Lno,Reason]), + io:format(standard_error, + "Tokeniser error on line: ~w ~w~n",[Lno,Reason]), exit(0); {NewLno,T} -> %%io:format('toks:~w~n',[T]), @@ -249,7 +250,7 @@ skip_comment([_|T]) -> skip_multiline_comment(Stream,[],Lno,Level) -> case io:get_line(Stream,'') of eof -> - io:format("Tokeniser error on line: ~w~n" + io:format(standard_error, "Tokeniser error on line: ~w~n" "premature end of multiline comment~n",[Lno]), exit(0); Line -> diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl index c24a7c238bd2..615f8c2541ac 100644 --- a/lib/common_test/src/ct_framework.erl +++ b/lib/common_test/src/ct_framework.erl @@ -280,7 +280,7 @@ add_defaults(Mod,Func, GroupPath, DoInit) -> ErrStr = io_lib:format("~n*** ERROR *** " "~w:suite/0 failed: ~p~n", [Suite,Reason]), - io:format(ErrStr, []), + io:format(standard_error, ErrStr, []), io:format(user, ErrStr, []), {suite0_failed,{exited,Reason}}; SuiteInfo when is_list(SuiteInfo) -> @@ -300,7 +300,7 @@ add_defaults(Mod,Func, GroupPath, DoInit) -> ErrStr = io_lib:format("~n*** ERROR *** " "Invalid return value from " "~w:suite/0: ~p~n", [Suite,SuiteInfo]), - io:format(ErrStr, []), + io:format(standard_error, ErrStr, []), io:format(user, ErrStr, []), {suite0_failed,bad_return_value} end; @@ -308,7 +308,7 @@ add_defaults(Mod,Func, GroupPath, DoInit) -> ErrStr = io_lib:format("~n*** ERROR *** " "Invalid return value from " "~w:suite/0: ~p~n", [Suite,SuiteInfo]), - io:format(ErrStr, []), + io:format(standard_error, ErrStr, []), io:format(user, ErrStr, []), {suite0_failed,bad_return_value} end. diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl index 19ad7b26d83d..66a4db275d24 100644 --- a/lib/common_test/src/ct_logs.erl +++ b/lib/common_test/src/ct_logs.erl @@ -126,7 +126,7 @@ close(Info, StartDir) -> ok -> ok; Error -> - io:format("Warning! Cleanup failed: ~p~n", [Error]) + io:format(standard_error, "Warning! Cleanup failed: ~p~n", [Error]) end, make_all_suites_index(stop), make_all_runs_index(stop); @@ -787,18 +787,20 @@ make_last_run_index(StartTime) -> AbsIndexName = ?abs(IndexName), case catch make_last_run_index1(StartTime,IndexName) of {'EXIT', Reason} -> - io:put_chars("CRASHED while updating " ++ AbsIndexName ++ "!\n"), - io:format("~p~n", [Reason]), + io:put_chars(standard_error, + "CRASHED while updating " ++ AbsIndexName ++ "!\n"), + io:format(standard_error, "~p~n", [Reason]), {error, Reason}; {error, Reason} -> - io:put_chars("FAILED while updating " ++ AbsIndexName ++ "\n"), - io:format("~p~n", [Reason]), + io:put_chars(standard_error, + "FAILED while updating " ++ AbsIndexName ++ "\n"), + io:format(standard_error, "~p~n", [Reason]), {error, Reason}; ok -> % io:put_chars("done\n"), ok; Err -> - io:format("Unknown internal error while updating ~s. " + io:format(standard_error, "Unknown internal error while updating ~s. " "Please report.\n(Err: ~p, ID: 1)", [AbsIndexName,Err]), {error, Err} @@ -1264,7 +1266,8 @@ count_cases(Dir) -> Summary end; {error, _Reason} -> - io:format("\nFailed to read ~p (skipped)\n", [LogFile]), + io:format(standard_error, + "\nFailed to read ~p (skipped)\n", [LogFile]), error end end. @@ -1612,17 +1615,19 @@ make_all_suites_index(NewTestData = {_TestName,DirName}) -> Label, LogDirData) of {'EXIT',Reason} -> - io:put_chars("CRASHED while updating " ++ AbsIndexName ++ "!\n"), - io:format("~p~n", [Reason]), + io:put_chars(standard_error, + "CRASHED while updating " ++ AbsIndexName ++ "!\n"), + io:format(standard_error, "~p~n", [Reason]), {error,Reason}; {error,Reason} -> - io:put_chars("FAILED while updating " ++ AbsIndexName ++ "\n"), - io:format("~p~n", [Reason]), + io:put_chars(standard_error, + "FAILED while updating " ++ AbsIndexName ++ "\n"), + io:format(standard_error, "~p~n", [Reason]), {error,Reason}; ok -> ok; Err -> - io:format("Unknown internal error while updating ~s. " + io:format(standard_error, "Unknown internal error while updating ~s. " "Please report.\n(Err: ~p, ID: 1)", [AbsIndexName,Err]), {error, Err} @@ -1662,12 +1667,14 @@ make_all_suites_index1(When, AbsIndexName, AllLogDirs) -> end, case catch make_all_suites_index2(IndexName, AllLogDirs) of {'EXIT', Reason} -> - io:put_chars("CRASHED while updating " ++ AbsIndexName ++ "!\n"), - io:format("~p~n", [Reason]), + io:put_chars(standard_error, + "CRASHED while updating " ++ AbsIndexName ++ "!\n"), + io:format(standard_error, "~p~n", [Reason]), {error, Reason}; {error, Reason} -> - io:put_chars("FAILED while updating " ++ AbsIndexName ++ "\n"), - io:format("~p~n", [Reason]), + io:put_chars(standard_error, + "FAILED while updating " ++ AbsIndexName ++ "\n"), + io:format(standard_error, "~p~n", [Reason]), {error, Reason}; {ok,CacheData} -> case When of @@ -1680,7 +1687,7 @@ make_all_suites_index1(When, AbsIndexName, AllLogDirs) -> ok end; Err -> - io:format("Unknown internal error while updating ~s. " + io:format(standard_error, "Unknown internal error while updating ~s. " "Please report.\n(Err: ~p, ID: 1)", [AbsIndexName,Err]), {error, Err} diff --git a/lib/common_test/src/ct_make.erl b/lib/common_test/src/ct_make.erl index 8ddb91d35543..1fb8f015ae09 100644 --- a/lib/common_test/src/ct_make.erl +++ b/lib/common_test/src/ct_make.erl @@ -95,7 +95,8 @@ read_emakefile(Emakefile,Opts) -> Mods = [filename:rootname(F) || F <- filelib:wildcard("*.erl")], [{Mods, Opts}]; {error,Other} -> - io:format("make: Trouble reading 'Emakefile':~n~p~n",[Other]), + io:format(standard_error, + "make: Trouble reading 'Emakefile':~n~p~n",[Other]), error end. @@ -150,7 +151,8 @@ get_opts_from_emakefile(Mods,Emakefile,Opts) -> {error,enoent} -> [{Mods, Opts}]; {error,Other} -> - io:format("make: Trouble reading 'Emakefile':~n~p~n",[Other]), + io:format(standard_error, + "make: Trouble reading 'Emakefile':~n~p~n",[Other]), error end. diff --git a/lib/common_test/src/ct_master.erl b/lib/common_test/src/ct_master.erl index 2ea2ba106a04..63c247adaad4 100644 --- a/lib/common_test/src/ct_master.erl +++ b/lib/common_test/src/ct_master.erl @@ -298,7 +298,7 @@ init_master(Parent,NodeOptsList,EvHandlers,MasterLogDir,LogDirs,InitOptions,Spec register(ct_master,self()), ok; _Pid -> - io:format("~nWarning: ct_master already running!~n"), + io:format(standard_error, "~nWarning: ct_master already running!~n"), exit(aborted) % case io:get_line('[y/n]>') of % "y\n" -> @@ -660,7 +660,8 @@ init_node_ctrl(MasterPid,Cookie,Opts) -> pong -> MasterPid ! {self(),{result,Result}}; pang -> - io:format("Warning! Connection to master node ~p is lost. " + io:format(standard_error, + "Warning! Connection to master node ~p is lost. " "Can't report result!~n~n", [MasterNode]) end. @@ -740,7 +741,8 @@ start_nodes(InitOptions)-> IsAlive = lists:member(NodeName, nodes()), case {HasNodeStart, IsAlive} of {false, false}-> - io:format("WARNING: Node ~p is not alive but has no node_start option~n", [NodeName]); + io:format(standard_error, + "WARNING: Node ~p is not alive but has no node_start option~n", [NodeName]); {false, true}-> io:format("Node ~p is alive~n", [NodeName]); {true, false}-> @@ -751,10 +753,12 @@ start_nodes(InitOptions)-> {ok, NodeName} -> io:format("Node ~p started successfully with callback ~p~n", [NodeName,Callback]); {error, Reason, _NodeName} -> - io:format("Failed to start node ~p with callback ~p! Reason: ~p~n", [NodeName, Callback, Reason]) + io:format(standard_error, + "Failed to start node ~p with callback ~p! Reason: ~p~n", [NodeName, Callback, Reason]) end; {true, true}-> - io:format("WARNING: Node ~p is alive but has node_start option~n", [NodeName]) + io:format(standard_error, + "WARNING: Node ~p is alive but has node_start option~n", [NodeName]) end end, InitOptions). @@ -767,7 +771,8 @@ eval_on_nodes(InitOptions)-> {false,_}-> ok; {true,false}-> - io:format("WARNING: Node ~p is not alive but has eval option ~n", [NodeName]); + io:format(standard_error, + "WARNING: Node ~p is not alive but has eval option ~n", [NodeName]); {true,true}-> {eval, MFAs} = lists:keyfind(eval, 1, Options), evaluate(NodeName, MFAs) @@ -778,7 +783,8 @@ eval_on_nodes(InitOptions)-> evaluate(Node, [{M,F,A}|MFAs])-> case rpc:call(Node, M, F, A) of {badrpc,Reason}-> - io:format("WARNING: Failed to call ~p:~p/~p on node ~p due to ~p~n", [M,F,length(A),Node,Reason]); + io:format(standard_error, + "WARNING: Failed to call ~p:~p/~p on node ~p due to ~p~n", [M,F,length(A),Node,Reason]); Result-> io:format("Called ~p:~p/~p on node ~p, result: ~p~n", [M,F,length(A),Node,Result]) end, diff --git a/lib/common_test/src/ct_repeat.erl b/lib/common_test/src/ct_repeat.erl index be3c485b7553..a2623f2164a6 100644 --- a/lib/common_test/src/ct_repeat.erl +++ b/lib/common_test/src/ct_repeat.erl @@ -42,7 +42,7 @@ loop_test(If,Args) when is_list(Args) -> no_loop -> false; {error,E} -> - io:format("Common Test error: ~p\n\n",[E]), + io:format(standard_error, "Common Test error: ~p\n\n",[E]), file:set_cwd(Cwd), E; {repeat,N} -> @@ -79,25 +79,27 @@ loop(If,Type,N,Data0,Data1,Args,TPid) -> Pid = spawn_tester(If,self(),Args), receive {'EXIT',Pid,Reason} -> - io:format("Test run crashed! This could be an internal error " + io:format(standard_error, + "Test run crashed! This could be an internal error " "- please report!\n\n" "~p\n\n",[Reason]), cancel(TPid), {error,Reason}; {Pid,{error,Reason}} -> - io:format("\nTest run failed!\nReason: ~p\n\n",[Reason]), + io:format(standard_error, "\nTest run failed!\nReason: ~p\n\n",[Reason]), cancel(TPid), {error,Reason}; {Pid,Result} -> if Type == repeat -> - io:format("\nTest run ~w(~w) complete.\n\n",[N+1,Data0]), + io:format("\nTest run ~w(~w) complete.\n\n",[N+1,Data0]), lists:keydelete(loop_info,1,Args), Args1 = [{loop_info,[{repeat,N+2,Data0}]} | Args], loop(If,repeat,N+1,Data0,Data1,Args1,TPid); Type == stop_time -> case remaining_time(Data1) of 0 -> - io:format("\nTest time (~s) has run out.\n\n",[ts(Data0)]), + io:format(standard_error, + "\nTest time (~s) has run out.\n\n",[ts(Data0)]), cancel(TPid), Result; Secs -> diff --git a/lib/common_test/src/ct_run.erl b/lib/common_test/src/ct_run.erl index 05b10bca3267..e13e5c423adf 100644 --- a/lib/common_test/src/ct_run.erl +++ b/lib/common_test/src/ct_run.erl @@ -140,16 +140,19 @@ script_start(Args) -> {'EXIT',Pid,Reason} -> case Reason of {user_error,What} -> - io:format("\nTest run failed!\nReason: ~p\n\n", [What]), + io:format(standard_error, + "\nTest run failed!\nReason: ~p\n\n", [What]), {error,What}; _ -> - io:format("Test run crashed! This could be an internal error " + io:format(standard_error, + "Test run crashed! This could be an internal error " "- please report!\n\n" "~p\n\n", [Reason]), {error,Reason} end; {Pid,{error,Reason}} -> - io:format("\nTest run failed! Reason:\n~p\n\n",[Reason]), + io:format(standard_error, + "\nTest run failed! Reason:\n~p\n\n",[Reason]), {error,Reason}; {Pid,Result} -> Result @@ -535,7 +538,7 @@ script_start4(#opts{vts = true, cover = Cover}, _) -> script_usage(); _ -> %% Add support later (maybe). - io:format("\nCan't run cover in vts mode.\n\n", []) + io:format(standard_error, "\nCan't run cover in vts mode.\n\n", []) end, erlang:halt(); @@ -545,7 +548,7 @@ script_start4(#opts{shell = true, cover = Cover}, _) -> script_usage(); _ -> %% Add support later (maybe). - io:format("\nCan't run cover in interactive mode.\n\n", []) + io:format(standard_error, "\nCan't run cover in interactive mode.\n\n", []) end; script_start4(Opts = #opts{tests = Tests}, Args) -> @@ -649,13 +652,15 @@ install(Opts, LogDir) -> file:close(Fd), ok; {error,Reason} -> - io:format("CT failed to install configuration data. Please " + io:format(standard_error, + "CT failed to install configuration data. Please " "verify that the log directory exists and that " "write permission is set.\n\n", []), {error,{VarFile,Reason}} end; _ -> - io:format("It is not possible to install CT while running " + io:format(standard_error, + "It is not possible to install CT while running " "in interactive mode.\n" "To exit this mode, run ct:stop_interactive().\n" "To enter the interactive mode again, " @@ -1721,7 +1726,7 @@ continue(_MakeErrors) -> R after 15000 -> exit(Pid, kill), - io:format("... timeout - continuing!!\n"), + io:format(standard_error, "... timeout - continuing!!\n"), true end; false -> % no shell process to use @@ -2550,12 +2555,14 @@ start_trace(Args) -> ok -> true; {_,Error} -> - io:format("Warning! Tracing not started. Reason: ~p~n~n", + io:format(standard_error, + "Warning! Tracing not started. Reason: ~p~n~n", [Error]), false end; {_,Error} -> - io:format("Warning! Tracing not started. Reason: ~s~n~n", + io:format(standard_error, + "Warning! Tracing not started. Reason: ~s~n~n", [file:format_error(Error)]), false end; diff --git a/lib/common_test/src/ct_telnet_client.erl b/lib/common_test/src/ct_telnet_client.erl index d703b39ac550..47be08ee27ba 100644 --- a/lib/common_test/src/ct_telnet_client.erl +++ b/lib/common_test/src/ct_telnet_client.erl @@ -310,7 +310,7 @@ cmd_dbg(_Cmd) -> end, io:format("~s(~w): ~w\n", [CtrlStr,Ctrl,Opts1]); Any -> - io:format("Unexpected in cmd_dbg:~n~w~n",[Any]) + io:format(standard_error, "Unexpected in cmd_dbg:~n~w~n",[Any]) end. -else. diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index 3b6ad6f98d8a..68c719637fc8 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -370,7 +370,7 @@ loop(Mode,TestData,StartDir) -> loop(Mode,TestData,StartDir); {'EXIT',Pid,Reason} -> %% Let process crash in case of error, this shouldn't happen! - io:format("\n\nct_util_server got EXIT from ~p: ~p\n\n", + io:format(standard_error, "\n\nct_util_server got EXIT from ~p: ~p\n\n", [Pid,Reason]), file:set_cwd(StartDir), exit(Reason) @@ -907,7 +907,7 @@ open_url(iexplore, Args, URL) -> io:format(user, "~nOpening ~s with command:~n ~s~n", [URL,Cmd1]), open_port({spawn,Cmd1}, []); _ -> - io:format("~nNo path to iexplore.exe~n",[]) + io:format(standard_error, "~nNo path to iexplore.exe~n",[]) end, win32reg:close(R), ok; diff --git a/lib/common_test/src/vts.erl b/lib/common_test/src/vts.erl index cc8a9328874e..131f89b2d8b5 100644 --- a/lib/common_test/src/vts.erl +++ b/lib/common_test/src/vts.erl @@ -249,7 +249,7 @@ loop(State) -> {'EXIT',Pid,Reason} -> case State#state.test_runner of Pid -> - io:format("Test run error: ~p\n",[Reason]), + io:format(standard_error, "Test run error: ~p\n",[Reason]), loop(State); _ -> loop(State) @@ -551,7 +551,7 @@ case_select(Dir,Suite,Case,N) -> code:add_pathz(Dir), case catch apply(Suite,all,[]) of {'EXIT',Reason} -> - io:format("\n~p\n",[Reason]), + io:format(standard_error, "\n~p\n",[Reason]), red(["COULD NOT READ TESTCASES!!",br(), "See erlang shell for info"]); {skip,_Reason} -> diff --git a/lib/compiler/src/beam_clean.erl b/lib/compiler/src/beam_clean.erl index a7994ab3b3f2..d7f0a3a0ce69 100644 --- a/lib/compiler/src/beam_clean.erl +++ b/lib/compiler/src/beam_clean.erl @@ -181,7 +181,8 @@ function_replace([{function,Name,Arity,Entry,Asm0}|Fs], Dict, Acc) -> replace(Asm0, [], Dict) catch throw:{error,{undefined_label,Lbl}=Reason} -> - io:format("Function ~s/~w refers to undefined label ~w\n", + io:format(standard_error, + "Function ~s/~w refers to undefined label ~w\n", [Name,Arity,Lbl]), exit(Reason) end, diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl index a52e7bb76198..8c527d0a9d9a 100644 --- a/lib/compiler/src/beam_validator.erl +++ b/lib/compiler/src/beam_validator.erl @@ -62,7 +62,7 @@ files([F|Fs]) -> case file(F) of ok -> ok; {error,Es} -> - io:format("~p:~n~s~n", [F,format_error(Es)]) + io:format(standard_error, "~p:~n~s~n", [F,format_error(Es)]) end, files(Fs); files([]) -> ok. diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index 9b505ad15c10..c3d540fd105f 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -135,11 +135,11 @@ env_default_opts() -> {ok,List} when is_list(List) -> List; {ok,Term} -> [Term]; {error,_Reason} -> - io:format("Ignoring bad term in ~s\n", [Key]), + io:format(standard_error, "Ignoring bad term in ~s\n", [Key]), [] end; {error, {_,_,_Reason}, _} -> - io:format("Ignoring bad term in ~s\n", [Key]), + io:format(standard_error, "Ignoring bad term in ~s\n", [Key]), [] end end. @@ -1414,7 +1414,7 @@ report_warnings(#compile{options=Opts,warnings=Ws0}) -> ({F,Eds}) -> format_message(F, P, Eds) end, Ws0), Ws = lists:sort(Ws1), - foreach(fun({_,Str}) -> io:put_chars(Str) end, Ws); + foreach(fun({_,Str}) -> io:put_chars(standard_error, Str) end, Ws); false -> ok end. @@ -1434,13 +1434,13 @@ format_message(_, _, []) -> []. %% list_errors(File, ErrorDescriptors) -> ok list_errors(F, [{{Line,Column},Mod,E}|Es]) -> - io:fwrite("~s:~w:~w: ~s\n", [F,Line,Column,Mod:format_error(E)]), + io:fwrite(standard_error, "~s:~w:~w: ~s\n", [F,Line,Column,Mod:format_error(E)]), list_errors(F, Es); list_errors(F, [{Line,Mod,E}|Es]) -> - io:fwrite("~s:~w: ~s\n", [F,Line,Mod:format_error(E)]), + io:fwrite(standard_error, "~s:~w: ~s\n", [F,Line,Mod:format_error(E)]), list_errors(F, Es); list_errors(F, [{Mod,E}|Es]) -> - io:fwrite("~s: ~s\n", [F,Mod:format_error(E)]), + io:fwrite(standard_error, "~s: ~s\n", [F,Mod:format_error(E)]), list_errors(F, Es); list_errors(_F, []) -> ok. diff --git a/lib/compiler/src/sys_pre_attributes.erl b/lib/compiler/src/sys_pre_attributes.erl index a6b7274b0702..14354ee3e91b 100644 --- a/lib/compiler/src/sys_pre_attributes.erl +++ b/lib/compiler/src/sys_pre_attributes.erl @@ -182,7 +182,7 @@ attrs([], _, _) -> report_error(Format, Args, S) -> case is_error(S) of true -> - io:format("~p: * ERROR * " ++ Format, [?MODULE | Args]); + io:format(standard_error, "~p: * ERROR * " ++ Format, [?MODULE | Args]); false -> ok end. @@ -190,7 +190,7 @@ report_error(Format, Args, S) -> report_warning(Format, Args, S) -> case is_warning(S) of true -> - io:format("~p: * WARNING * " ++ Format, [?MODULE | Args]); + io:format(standard_error, "~p: * WARNING * " ++ Format, [?MODULE | Args]); false -> ok end. diff --git a/lib/dialyzer/src/dialyzer.erl b/lib/dialyzer/src/dialyzer.erl index 3e3c12405f62..7444addd746c 100644 --- a/lib/dialyzer/src/dialyzer.erl +++ b/lib/dialyzer/src/dialyzer.erl @@ -271,7 +271,7 @@ cl_halt({ok, R = ?RET_DISCREPANCIES}, #options{output_file = Output}) -> halt(R); cl_halt({error, Msg1}, #options{output_file = Output}) -> %% Msg2 = "dialyzer: Internal problems were encountered in the analysis", - io:format("\ndialyzer: ~s\n", [Msg1]), + io:format(standard_error, "\ndialyzer: ~s\n", [Msg1]), cl_check_log(Output), halt(?RET_INTERNAL_ERROR). diff --git a/lib/edoc/src/edoc.erl b/lib/edoc/src/edoc.erl index 544465b14a50..740dce2bbb4d 100644 --- a/lib/edoc/src/edoc.erl +++ b/lib/edoc/src/edoc.erl @@ -175,7 +175,7 @@ application(App, Options) when is_atom(App) -> Dir when is_list(Dir) -> application(App, Dir, Options); _ -> - edoc_report:report("cannot find application directory for '~s'.", + edoc_report:report_error("cannot find application directory for '~s'.", [App]), exit(error) end. @@ -686,7 +686,7 @@ check_forms(Fs, Name) -> {L, M, D} -> edoc_report:error(L, Name, {format_error, M, D}); Other -> - edoc_report:report(Name, "unknown error in " + edoc_report:report_error(Name, "unknown error in " "source code: ~w.", [Other]) end, exit(error); diff --git a/lib/edoc/src/edoc_report.erl b/lib/edoc/src/edoc_report.erl index 9bec08ab973d..ca4d0b54be6f 100644 --- a/lib/edoc/src/edoc_report.erl +++ b/lib/edoc/src/edoc_report.erl @@ -33,6 +33,9 @@ report/2, report/3, report/4, + report_error/2, + report_error/3, + report_error/4, warning/1, warning/2, warning/3, @@ -48,11 +51,11 @@ error(Where, What) -> error(0, Where, What). error(Line, Where, S) when is_list(S) -> - report(Line, Where, S, []); + report_error(Line, Where, S, []); error(Line, Where, {S, D}) when is_list(S) -> - report(Line, Where, S, D); + report_error(Line, Where, S, D); error(Line, Where, {format_error, M, D}) -> - report(Line, Where, M:format_error(D), []). + report_error(Line, Where, M:format_error(D), []). warning(S) -> warning(S, []). @@ -64,7 +67,7 @@ warning(Where, S, Vs) -> warning(0, Where, S, Vs). warning(L, Where, S, Vs) -> - report(L, Where, "warning: " ++ S, Vs). + report_error(L, Where, "warning: " ++ S, Vs). report(S, Vs) -> report([], S, Vs). @@ -82,6 +85,22 @@ report(L, Where, S, Vs) -> io:fwrite(S, Vs), io:nl(). +report_error(S, Vs) -> + report_error([], S, Vs). + +report_error(Where, S, Vs) -> + report_error(0, Where, S, Vs). + +report_error(L, Where, S, Vs) -> + io:put_chars(standard_error, where(Where)), + if is_integer(L), L > 0 -> + io:fwrite(standard_error, "at line ~w: ", [L]); + true -> + ok + end, + io:fwrite(standard_error, S, Vs), + io:nl(standard_error). + where({File, module}) -> io_lib:fwrite("~s, in module header: ", [File]); where({File, footer}) -> diff --git a/lib/eunit/src/eunit_server.erl b/lib/eunit/src/eunit_server.erl index 2002930abb59..d369a03baff2 100644 --- a/lib/eunit/src/eunit_server.erl +++ b/lib/eunit/src/eunit_server.erl @@ -325,8 +325,9 @@ auto_super(Server, M) -> ok after ?AUTO_TIMEOUT -> exit(Pid, kill), - io:put_chars("\n== EUnit: automatic test was aborted ==\n"), - io:put_chars("\n> ") + io:put_chars(standard_error, + "\n== EUnit: automatic test was aborted ==\n"), + io:put_chars(standard_error, "\n> ") end, Server ! {done, auto_test, self()}. diff --git a/lib/eunit/src/eunit_tty.erl b/lib/eunit/src/eunit_tty.erl index e3e7b710b21e..333af0f608f3 100644 --- a/lib/eunit/src/eunit_tty.erl +++ b/lib/eunit/src/eunit_tty.erl @@ -82,7 +82,7 @@ terminate({ok, Data}, St) -> sync_end(error) end; terminate({error, Reason}, _St) -> - io:fwrite("Internal error: ~P.\n", [Reason, 25]), + io:fwrite(standard_error, "Internal error: ~P.\n", [Reason, 25]), sync_end(error). sync_end(Result) -> @@ -212,18 +212,18 @@ print_test_end(Data) -> print_test_error({error, Exception}, Data) -> Output = proplists:get_value(output, Data), - io:fwrite("*failed*\n::~s", + io:fwrite(standard_error, "*failed*\n::~s", [eunit_lib:format_exception(Exception)]), case Output of <<>> -> - io:put_chars("\n\n"); + io:put_chars(standard_error, "\n\n"); <> -> - io:fwrite(" output:<<\"~s\">>...\n\n", [Text]); + io:fwrite(standard_error, " output:<<\"~s\">>...\n\n", [Text]); _ -> - io:fwrite(" output:<<\"~s\">>\n\n", [Output]) + io:fwrite(standard_error, " output:<<\"~s\">>\n\n", [Output]) end; print_test_error({skipped, Reason}, _) -> - io:fwrite("*did not run*\n::~s\n", [format_skipped(Reason)]). + io:fwrite(standard_error, "*did not run*\n::~s\n", [format_skipped(Reason)]). format_skipped({module_not_found, M}) -> io_lib:format("missing module: ~w", [M]); @@ -231,13 +231,13 @@ format_skipped({no_such_function, {M,F,A}}) -> io_lib:format("no such function: ~w:~w/~w", [M,F,A]). print_test_cancel(Reason) -> - io:fwrite(format_cancel(Reason)). + io:fwrite(standard_error, format_cancel(Reason)). print_group_cancel(_I, {blame, _}) -> ok; print_group_cancel(I, Reason) -> indent(I), - io:fwrite(format_cancel(Reason)). + io:fwrite(standard_error, format_cancel(Reason)). format_cancel(undefined) -> "*skipped*\n"; diff --git a/lib/hipe/cerl/cerl_cconv.erl b/lib/hipe/cerl/cerl_cconv.erl index cf4d317b0de1..0c2814a886b6 100644 --- a/lib/hipe/cerl/cerl_cconv.erl +++ b/lib/hipe/cerl/cerl_cconv.erl @@ -552,7 +552,7 @@ fun_info(E, Env, S) -> %% io:fwrite("Got fun-info: ~w: {~w,~w}.\n", [Name,Id,H]), {#fun_info{name = Name, id = Id, hash = H}, S}; _ -> - io:fwrite("Warning - fun not annotated: " + io:fwrite(standard_error, "Warning - fun not annotated: " "making up new name.\n"), % for now {{Name,_Arity}, S1} = new_fun_name(E, Env, S), {#fun_info{name = Name, id = 0, hash = 0}, S1} diff --git a/lib/hipe/icode/hipe_icode_type.erl b/lib/hipe/icode/hipe_icode_type.erl index 3f9488d7c331..109b5cd99622 100644 --- a/lib/hipe/icode/hipe_icode_type.erl +++ b/lib/hipe/icode/hipe_icode_type.erl @@ -1266,7 +1266,8 @@ strength_reduce(I, Op) -> case hipe_icode:is_const(Arg2) of true -> case hipe_icode:const_value(Arg2) of - 0 -> io:fwrite("Integer division by 0 detected!\n"), I; + 0 -> io:fwrite(standard_error, + "Integer division by 0 detected!\n"), I; 1 -> case call_dstlist(I) of [] -> remove_useless_arithmetic_instruction(I); [Dst] -> create_strength_reduce_move(I, Dst, Arg1) @@ -1293,7 +1294,8 @@ strength_reduce(I, Op) -> case hipe_icode:is_const(Arg2) of true -> case hipe_icode:const_value(Arg2) of - 0 -> io:fwrite("Remainder with 0 detected!\n"), I; + 0 -> io:fwrite(standard_error, + "Remainder with 0 detected!\n"), I; 1 -> case call_dstlist(I) of [] -> remove_useless_arithmetic_instruction(I); [Dst] -> create_strength_reduce_move( diff --git a/lib/ic/src/ic.erl b/lib/ic/src/ic.erl index 50fad921c4e6..7fcbc9b59833 100644 --- a/lib/ic/src/ic.erl +++ b/lib/ic/src/ic.erl @@ -81,19 +81,19 @@ gen(File, Opts) -> case catch gen2(G, File, Opts) of {_, {'EXIT', R}} -> ic_genobj:free_table_space(G), %% Free space for all ETS tables - io:format("Fatal error : ~p~n",[R]), + io:format(standard_error, "Fatal error : ~p~n",[R]), error; {_, {'EXIT', _, R}} -> ic_genobj:free_table_space(G), %% Free space for all ETS tables - io:format("Fatal error : ~p~n",[R]), + io:format(standard_error, "Fatal error : ~p~n",[R]), error; {'EXIT', R} -> ic_genobj:free_table_space(G), %% Free space for all ETS tables - io:format("Fatal error : ~p~n",[R]), + io:format(standard_error, "Fatal error : ~p~n",[R]), error; {'EXIT', _, R} -> ic_genobj:free_table_space(G), %% Free space for all ETS tables - io:format("Fatal error : ~p~n",[R]), + io:format(standard_error, "Fatal error : ~p~n",[R]), error; %% In this case, the pragma registration %% found errors so this should return error. @@ -335,7 +335,7 @@ typing(G, File, Clean) -> time("type code appliance ", ic, do_type, [G,Clean]), ic:do_type(G,Clean)) of {'EXIT',Reason} -> - io:format("Error under type appliance : ~p~n",[Reason]), + io:format(standard_error, "Error under type appliance : ~p~n",[Reason]), error; T2 -> diff --git a/lib/ic/src/ic_error.erl b/lib/ic/src/ic_error.erl index f41e78a8be1a..d336bd33db89 100644 --- a/lib/ic/src/ic_error.erl +++ b/lib/ic/src/ic_error.erl @@ -307,11 +307,11 @@ format_warn({warn, _, File, {WarnString, Line}}) -> %% Display an error or warning display(File, not_specified, F, A) -> - io:format("~p : ~s~n", [File, io_lib:format(F, A)]); + io:format(standard_error, "~p : ~s~n", [File, io_lib:format(F, A)]); display(File, Line, F, A) -> - io:format("~p on line ~p: ~s~n", [File, Line, io_lib:format(F, A)]). + io:format(standard_error, "~p on line ~p: ~s~n", [File, Line, io_lib:format(F, A)]). display(File, F, A) -> - io:format("~p: ~s~n", [File, io_lib:format(F, A)]). + io:format(standard_error, "~p: ~s~n", [File, io_lib:format(F, A)]). @@ -319,7 +319,7 @@ display(File, F, A) -> %% case {ic_options:get_opt(G, silent), ic_options:get_opt(G, silent2), %% ic_options:get_opt(G, nowarn)} of %% {false, false, false} -> -%% io:format("~p: warning: ~s~n", [ic_genobj:idlfile(G), WarnStr]); +%% io:format(standard_error, "~p: warning: ~s~n", [ic_genobj:idlfile(G), WarnStr]); %% _ -> ok %% end. @@ -327,7 +327,7 @@ display(File, F, A) -> %% case {ic_options:get_opt(G, silent), ic_options:get_opt(G, silent2), %% ic_options:get_opt(G, nowarn)} of %% {false, false, false} -> -%% io:format("~p on line ~p: warning: ~s~n", +%% io:format(standard_error, "~p on line ~p: warning: ~s~n", %% [ic_genobj:idlfile(G), Line, WarnStr]); %% _ -> ok %% end. diff --git a/lib/ic/src/ic_jbe.erl b/lib/ic/src/ic_jbe.erl index 81798d0429d4..f6feb8127da0 100644 --- a/lib/ic/src/ic_jbe.erl +++ b/lib/ic/src/ic_jbe.erl @@ -296,7 +296,8 @@ gen_member_2(G, N, X, [_T|Ts]) -> gen_exception(_G, N, X) -> - io:format("Warning : Exceptions not supported for java mapping, ~p ignored\n", + io:format(standard_error, + "Warning : Exceptions not supported for java mapping, ~p ignored\n", [ic_util:to_colon([ic_forms:get_java_id(X)|N])]), ok. diff --git a/lib/ic/src/ic_pp.erl b/lib/ic/src/ic_pp.erl index 8b53473caac7..43eb605be7bb 100644 --- a/lib/ic/src/ic_pp.erl +++ b/lib/ic/src/ic_pp.erl @@ -648,11 +648,11 @@ expand(List, Defs, Err, War, [FileName|IncFile], IncDir, Mio) -> %% Main loop for the expansion %%======================================================= expand([], Out, _SelfRef, Defs, _IncFile, _IncDir, Mio, IfCou, Err, War, _L, _FN) -> -% io:format("~n ===============~n"), -% io:format(" definitions ~p~n",[lists:reverse(Defs)]), -% io:format(" found warnings ~p~n",[lists:reverse(War)]), -% io:format(" found errors ~p~n",[lists:reverse(Err)]), -% io:format(" ===============~n~n~n"), +% io:format(standard_error, "~n ===============~n"), +% io:format(standard_error, " definitions ~p~n",[lists:reverse(Defs)]), +% io:format(standard_error, " found warnings ~p~n",[lists:reverse(War)]), +% io:format(standard_error, " found errors ~p~n",[lists:reverse(Err)]), +% io:format(standard_error, " ===============~n~n~n"), {Out, Err, War, Defs, Mio, IfCou}; expand([{file_info, Str} | Rem], Out, SelfRef, Defs, IncFile, IncDir, Mio, IfCou, Err, War, L, FN) -> @@ -856,7 +856,7 @@ expand([{command,Command} | Rem], Out, SelfRef, Defs, IncFile, IncDir, Mio, chec end; Else -> -% io:format(" %%%%Else%%%%%% ~p~n",[Else]), +% io:format(standard_error, " %%%%Else%%%%%% ~p~n",[Else]), exit(Else) end; diff --git a/lib/ic/src/ic_pragma.erl b/lib/ic/src/ic_pragma.erl index beaa2852ab9b..6b5ff2eb3d08 100644 --- a/lib/ic/src/ic_pragma.erl +++ b/lib/ic/src/ic_pragma.erl @@ -71,11 +71,11 @@ pragma_reg(G,X) -> %% Just print the number of errors found case ErrorNr > 1 of true -> - io:format("There were ~p errors found on file ~p~n", + io:format(standard_error, "There were ~p errors found on file ~p~n", [ErrorNr,get_idlfile(S)]), error; false -> - io:format("There were ~p error found on file ~p~n", + io:format(standard_error, "There were ~p error found on file ~p~n", [ErrorNr,get_idlfile(S)]), error end @@ -218,8 +218,8 @@ pragma_reg(G, S, N, X) when element(1, X) == pragma -> pragma_reg_codeOpt(G,S,N,X); {pragma,{_,LineNr,BadPragma}, _To, _Apply} -> - io:format("Warning : on file ~p :~n",[get_idlfile(S)]), - io:format(" Unknown pragma directive ~p on line ~p, ignored.~n", + io:format(standard_error, "Warning : on file ~p :~n",[get_idlfile(S)]), + io:format(standard_error, " Unknown pragma directive ~p on line ~p, ignored.~n", [BadPragma,LineNr]) end; @@ -346,17 +346,17 @@ pragma_reg_ID(G, S, N, X) -> insert(S,{id,X,LineNr,N,File,Type}); false -> set_compilation_failure(S), - io:format("Error on file ~p :~n",[get_idlfile(S)]), - io:format(" Bad pragma ID ~p on line ~p,~n", + io:format(standard_error, "Error on file ~p :~n",[get_idlfile(S)]), + io:format(standard_error, " Bad pragma ID ~p on line ~p,~n", [element(3,Apply),LineNr]), - io:format(" the version part of ID is not a short integer.~n") + io:format(standard_error, " the version part of ID is not a short integer.~n") end; ["LOCAL"|_] -> insert(S,{id,X,LineNr,N,File,Type}); _ -> set_compilation_failure(S), - io:format("Error on file ~p :~n",[get_idlfile(S)]), - io:format(" Bad pragma ID ~p on line ~p.~n", + io:format(standard_error, "Error on file ~p :~n",[get_idlfile(S)]), + io:format(standard_error, " Bad pragma ID ~p on line ~p.~n", [element(3,Apply),LineNr]) end. @@ -380,17 +380,17 @@ pragma_reg_version(G, S, N, X) -> insert(S,{version,X,LineNr,N,File,Type}); false -> set_compilation_failure(S), - io:format("Error on file ~p :~n",[get_idlfile(S)]), - io:format(" Bad pragma version ~p on line ~p,~n", + io:format(standard_error, "Error on file ~p :~n",[get_idlfile(S)]), + io:format(standard_error, " Bad pragma version ~p on line ~p,~n", [Apply,LineNr]), - io:format(" the version is not valid.~n") + io:format(standard_error, " the version is not valid.~n") end; _ -> set_compilation_failure(S), - io:format("Error on file ~p :~n",[get_idlfile(S)]), - io:format(" Bad pragma version ~p on line ~p,~n", + io:format(standard_error, "Error on file ~p :~n",[get_idlfile(S)]), + io:format(standard_error, " Bad pragma version ~p on line ~p,~n", [Apply,LineNr]), - io:format(" the version is not valid.~n") + io:format(standard_error, " the version is not valid.~n") end. @@ -466,8 +466,8 @@ applyCodeOpts(G,S,LNr,[X|Xs]) -> applyCodeOpts(G,S,LNr,Xs); false -> %% Print warning and continue - io:format("Warning on file ~p :~n",[get_idlfile(S)]), - io:format(" Bad option in pragma : ~p, ignored !~n",[X]), + io:format(standard_error, "Warning on file ~p :~n",[get_idlfile(S)]), + io:format(standard_error, " Bad option in pragma : ~p, ignored !~n",[X]), applyCodeOpts(G,S,LNr,Xs) end. diff --git a/lib/ic/src/icstruct.erl b/lib/ic/src/icstruct.erl index 6058b3c45547..f62a3069801c 100644 --- a/lib/ic/src/icstruct.erl +++ b/lib/ic/src/icstruct.erl @@ -62,7 +62,8 @@ except_gen(G, N, X, L) when is_record(X, except) -> N2 = [ic_forms:get_id2(X) | N], if L == c -> - io:format("Warning : Exception not defined for c mapping\n", []); + io:format(standard_error, + "Warning : Exception not defined for c mapping\n", []); true -> emit_struct(G, N, X, L) end, diff --git a/lib/ic/src/ictype.erl b/lib/ic/src/ictype.erl index 9e20801464c3..0b77bf9432b8 100644 --- a/lib/ic/src/ictype.erl +++ b/lib/ic/src/ictype.erl @@ -1065,7 +1065,7 @@ calc_inherit_body(G, N, OrigBody, [X|Xs], InhBody) -> Body = filter_body(G, X, ic_forms:get_body(Intf), N, OrigBody, InhBody), calc_inherit_body(G, N, OrigBody, Xs, [{X, Body} | InhBody]); XXX -> - io:format("Oops, not found ~p~n", [XXX]), + io:format(standard_error, "Oops, not found ~p~n", [XXX]), calc_inherit_body(G, N, OrigBody, Xs, InhBody) end; calc_inherit_body(_G, _N, _OrigBody, [], InhBody) -> lists:reverse(InhBody). diff --git a/lib/parsetools/src/leex.erl b/lib/parsetools/src/leex.erl index cdf20461d993..bed51202ca2e 100644 --- a/lib/parsetools/src/leex.erl +++ b/lib/parsetools/src/leex.erl @@ -298,10 +298,10 @@ pack_warnings([]) -> report_errors(St) -> when_opt(fun () -> foreach(fun({File,{none,Mod,E}}) -> - io:fwrite("~s: ~s\n", + io:fwrite(standard_error, "~s: ~s\n", [File,Mod:format_error(E)]); ({File,{Line,Mod,E}}) -> - io:fwrite("~s:~w: ~s\n", + io:fwrite(standard_error, "~s:~w: ~s\n", [File,Line,Mod:format_error(E)]) end, sort(St#leex.errors)) end, report_errors, St#leex.opts). @@ -316,11 +316,11 @@ report_warnings(St) -> ShouldReport = member(report_warnings, St#leex.opts) orelse ReportWerror, when_bool(fun () -> foreach(fun({File,{none,Mod,W}}) -> - io:fwrite("~s: ~s~s\n", + io:fwrite(standard_error, "~s: ~s~s\n", [File,Prefix, Mod:format_error(W)]); ({File,{Line,Mod,W}}) -> - io:fwrite("~s:~w: ~s~s\n", + io:fwrite(standard_error, "~s:~w: ~s~s\n", [File,Line,Prefix, Mod:format_error(W)]) end, sort(St#leex.warnings)) diff --git a/lib/parsetools/src/yecc.erl b/lib/parsetools/src/yecc.erl index b0792a6ed808..00afa934d0c4 100644 --- a/lib/parsetools/src/yecc.erl +++ b/lib/parsetools/src/yecc.erl @@ -841,10 +841,10 @@ report_errors(St) -> case member(report_errors, St#yecc.options) of true -> foreach(fun({File,{none,Mod,E}}) -> - io:fwrite(<<"~s: ~s\n">>, + io:fwrite(standard_error, <<"~s: ~s\n">>, [File,Mod:format_error(E)]); ({File,{Line,Mod,E}}) -> - io:fwrite(<<"~s:~w: ~s\n">>, + io:fwrite(standard_error, <<"~s:~w: ~s\n">>, [File,Line,Mod:format_error(E)]) end, sort(St#yecc.errors)); false -> @@ -861,11 +861,11 @@ report_warnings(St) -> case member(report_warnings, St#yecc.options) orelse ReportWerror of true -> foreach(fun({File,{none,Mod,W}}) -> - io:fwrite(<<"~s: ~s~s\n">>, + io:fwrite(standard_error, <<"~s: ~s~s\n">>, [File,Prefix, Mod:format_error(W)]); ({File,{Line,Mod,W}}) -> - io:fwrite(<<"~s:~w: ~s~s\n">>, + io:fwrite(standard_error, <<"~s:~w: ~s~s\n">>, [File,Line,Prefix, Mod:format_error(W)]) end, sort(St#yecc.warnings)); @@ -1549,12 +1549,13 @@ find_action_conflicts(St0) -> end, {Cxt0, []}, St0#yecc.parse_actions), if length(Res) > 0, St#yecc.verbose -> - io:fwrite(<<"\n*** Conflicts resolved by operator " + io:fwrite(standard_error, + <<"\n*** Conflicts resolved by operator " "precedences:\n\n">>), foreach(fun({Confl, Name}) -> report_conflict(Confl, St, Name, prec) end, reverse(Res)), - io:fwrite(<<"*** End of resolved conflicts\n\n">>); + io:fwrite(standard_error, <<"*** End of resolved conflicts\n\n">>); true -> ok end, diff --git a/lib/parsetools/src/yeccscan.erl b/lib/parsetools/src/yeccscan.erl index d7ec3ba8d355..79dee6b34d94 100644 --- a/lib/parsetools/src/yeccscan.erl +++ b/lib/parsetools/src/yeccscan.erl @@ -37,7 +37,8 @@ scan(Inport, Prompt, Line1) -> {error, Descriptor, Line2} -> {error, Descriptor, Line2}; {'EXIT', Why} -> - io:format('yeccscan: Error scanning input line ~w~n', [Line1]), + io:format(standard_error, + 'yeccscan: Error scanning input line ~w~n', [Line1]), exit(Why) end. diff --git a/lib/reltool/src/reltool.erl b/lib/reltool/src/reltool.erl index 54eb1ca9e164..c531cb75304f 100644 --- a/lib/reltool/src/reltool.erl +++ b/lib/reltool/src/reltool.erl @@ -120,7 +120,8 @@ apply_fun(Pid, false, Fun) -> apply_fun(Pid, true, Fun) -> case get_status(Pid) of {ok, Warnings} -> - [io:format("~p: ~s\n", [?APPLICATION, W]) || W <- Warnings], + [io:format(standard_error, "~p: ~s\n", [?APPLICATION, W]) + || W <- Warnings], apply_fun(Pid, false, Fun); {error, _Reason} = Error -> stop(Pid), diff --git a/lib/reltool/src/reltool_sys_win.erl b/lib/reltool/src/reltool_sys_win.erl index 8b0f64eb4529..084db316c5c0 100644 --- a/lib/reltool/src/reltool_sys_win.erl +++ b/lib/reltool/src/reltool_sys_win.erl @@ -175,12 +175,13 @@ do_init([{safe_config, Safe}, {parent, Parent} | Options]) -> restart_server_safe_config(Safe,Parent,Reason) end; {error, Reason} -> - io:format("~p(~p): ~p\n", [?MODULE, ?LINE, Reason]), + io:format(standard_error, "~p(~p): ~p\n", + [?MODULE, ?LINE, Reason]), exit(Reason) end. restart_server_safe_config(true,_Parent,Reason) -> - io:format("~p(~p): ~p\n", [?MODULE, ?LINE, Reason]), + io:format(standard_error, "~p(~p): ~p\n", [?MODULE, ?LINE, Reason]), exit(Reason); restart_server_safe_config(false,Parent,Reason) -> Strings = @@ -196,7 +197,8 @@ restart_server_safe_config(false,Parent,Reason) -> ?wxID_OK -> do_init([{safe_config,true},{parent,Parent},?safe_config]); ?wxID_CANCEL -> - io:format("~p(~p): ~p\n", [?MODULE, ?LINE, Reason]), + io:format(standard_error, "~p(~p): ~p\n", + [?MODULE, ?LINE, Reason]), exit(Reason) end. @@ -209,7 +211,8 @@ exit_dialog(Warnings) -> ?wxID_OK -> ok; ?wxID_CANCEL -> - io:format("~p(~p): ~s\n", [?MODULE, ?LINE, Details]), + io:format(standard_error, "~p(~p): ~s\n", + [?MODULE, ?LINE, Details]), exit(Details) end. diff --git a/lib/sasl/src/systools.erl b/lib/sasl/src/systools.erl index 51ef687047d0..e3fe8561e3c5 100644 --- a/lib/sasl/src/systools.erl +++ b/lib/sasl/src/systools.erl @@ -72,7 +72,7 @@ make_tar(RelName, Opt) -> script2boot(File) -> case systools_lib:file_term2binary(File ++ ".script", File ++ ".boot") of {error,Error} -> - io:format(systools_make:format_error(Error)), + io:format(standard_error, systools_make:format_error(Error)), error; _ -> ok @@ -83,7 +83,7 @@ script2boot(File, Output0, _Opt) -> Output = Output0++".boot", case systools_lib:file_term2binary(Input, Output) of {error,Error} -> - io:format(systools_make:format_error(Error)), + io:format(standard_error, systools_make:format_error(Error)), error; _ -> ok diff --git a/lib/sasl/src/systools_make.erl b/lib/sasl/src/systools_make.erl index 12ba2a5476f6..6e3beeee374c 100644 --- a/lib/sasl/src/systools_make.erl +++ b/lib/sasl/src/systools_make.erl @@ -156,10 +156,10 @@ return(ok,Warnings,Flags) -> _ -> case member(warnings_as_errors,Flags) of true -> - io:format("~s",[format_warning(Warnings, true)]), + io:format(standard_error,"~s",[format_warning(Warnings, true)]), error; false -> - io:format("~s",[format_warning(Warnings)]), + io:format(standard_error,"~s",[format_warning(Warnings)]), ok end end; @@ -168,7 +168,7 @@ return({error,Mod,Error},_,Flags) -> true -> {error,Mod,Error}; _ -> - io:format("~s",[Mod:format_error(Error)]), + io:format(standard_error,"~s",[Mod:format_error(Error)]), error end. @@ -903,7 +903,7 @@ check_modules(Appls, Path, TestP, Machine) -> Return end; Dups -> -% io:format("** ERROR Duplicate modules: ~p\n", [Dups]), +% io:format(standard_error, "** ERROR Duplicate modules: ~p\n", [Dups]), throw({error, {duplicate_modules, Dups}}) end. diff --git a/lib/sasl/src/systools_relup.erl b/lib/sasl/src/systools_relup.erl index 7fb623bb853f..b129f91f34b7 100644 --- a/lib/sasl/src/systools_relup.erl +++ b/lib/sasl/src/systools_relup.erl @@ -595,9 +595,9 @@ print_error({'EXIT', Err}) -> print_error(Err); print_error({error, Mod, Error}) -> S = apply(Mod, format_error, [Error]), - io:format(S, []); + io:format(standard_error, S, []); print_error(Other) -> - io:format("Error: ~p~n", [Other]). + io:format(standard_error, "Error: ~p~n", [Other]). format_error({file_problem, {"relup", _Posix}}) -> io_lib:format("Could not open file relup~n", []); @@ -612,7 +612,7 @@ format_error({missing_sasl,Release}) -> io_lib:format("No sasl application in release ~p, ~p. Can not be upgraded.", [Release#release.name, Release#release.vsn]); format_error(Error) -> - io:format("~p~n", [Error]). + io:format(standard_error, "~p~n", [Error]). print_warnings(Ws, Opts) when is_list(Ws) -> @@ -628,7 +628,7 @@ print_warning(W, Opts) -> "*WARNING* " end, S = format_warning(Prefix, W), - io:format("~s", [S]). + io:format(standard_error, "~s", [S]). format_warning(W) -> format_warning("*WARNING* ", W). diff --git a/lib/snmp/src/agent/snmpa_error_io.erl b/lib/snmp/src/agent/snmpa_error_io.erl index 54cdb6baac69..91ae752ec1de 100644 --- a/lib/snmp/src/agent/snmpa_error_io.erl +++ b/lib/snmp/src/agent/snmpa_error_io.erl @@ -45,5 +45,5 @@ config_err(F, A) -> error_msg(P, F, A) -> - io:format("*** SNMP ~s *** ~n" ++ F ++ "~n", [P|A]). + io:format(standard_error, "*** SNMP ~s *** ~n" ++ F ++ "~n", [P|A]). diff --git a/lib/snmp/src/compile/snmpc.erl b/lib/snmp/src/compile/snmpc.erl index 5e6b81f1ecf9..01d908dbc180 100644 --- a/lib/snmp/src/compile/snmpc.erl +++ b/lib/snmp/src/compile/snmpc.erl @@ -63,7 +63,7 @@ compile(Input, _Output, Options) -> {ok, _} -> ok; {error, Reason} -> - io:format("~p", [Reason]), + io:format(standard_error, "~p", [Reason]), error end. diff --git a/lib/snmp/src/compile/snmpc_lib.erl b/lib/snmp/src/compile/snmpc_lib.erl index 38bb8f3ac661..14351d6593cd 100644 --- a/lib/snmp/src/compile/snmpc_lib.erl +++ b/lib/snmp/src/compile/snmpc_lib.erl @@ -482,8 +482,8 @@ is_consistent(Filenames) -> ok -> ok; {undef, Format, Data} -> - ok = io:format(Format, Data), - io:format("~n"), + ok = io:format(standard_error, Format, Data), + io:format(standard_error, "~n"), {error, inconsistent} end. @@ -1754,14 +1754,15 @@ error(FormatStr, Data, Line) when is_list(FormatStr) -> exit(error). print_error(FormatStr, Data) when is_list(FormatStr) -> - ok = io:format("~s: " ++ FormatStr,[get(filename)|Data]), + ok = io:format(standard_error, "~s: " ++ FormatStr,[get(filename)|Data]), put(errors,yes), - io:format("~n"). + io:format(standard_error, "~n"). print_error(FormatStr, Data,Line) when is_list(FormatStr) -> - ok = io:format("~s: ~w: " ++ FormatStr,[get(filename), Line |Data]), + ok = io:format(standard_error, "~s: ~w: " ++ FormatStr, + [get(filename), Line |Data]), put(errors,yes), - io:format("~n"). + io:format(standard_error, "~n"). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/lib/snmp/src/compile/snmpc_mib_to_hrl.erl b/lib/snmp/src/compile/snmpc_mib_to_hrl.erl index e8c46a052140..6f3442916ece 100644 --- a/lib/snmp/src/compile/snmpc_mib_to_hrl.erl +++ b/lib/snmp/src/compile/snmpc_mib_to_hrl.erl @@ -337,7 +337,7 @@ compile(Input, Output, Opts) -> ok -> ok; {error, Reason} -> - io:format("~p", [Reason]), + io:format(standard_error, "~p", [Reason]), error end. diff --git a/lib/stdlib/src/c.erl b/lib/stdlib/src/c.erl index a920921a5ede..f63a63bc4138 100644 --- a/lib/stdlib/src/c.erl +++ b/lib/stdlib/src/c.erl @@ -35,7 +35,7 @@ -import(lists, [reverse/1,flatten/1,sublist/3,sort/1,keysort/2, concat/1,max/1,min/1,foreach/2,foldl/3,flatmap/2]). --import(io, [format/1, format/2]). +-import(io, [format/1, format/2, format/3]). %%----------------------------------------------------------------------- @@ -122,12 +122,14 @@ machine_load(Mod, File, Opts) -> code:purge(Mod), check_load(code:load_abs(File2,Mod), Mod); _OtherMod -> - format("** Module name '~p' does not match file name '~p' **~n", + format(standard_error, + "** Module name '~p' does not match file name '~p' **~n", [Mod,File]), {error, badfile} end; false -> - format("** Warning: No object file created - nothing loaded **~n", []), + format(standard_error, + "** Warning: No object file created - nothing loaded **~n", []), ok end. @@ -162,7 +164,7 @@ lc(Args) -> -spec lc_batch() -> no_return(). lc_batch() -> - io:format("Error: no files to compile~n"), + io:format(standard_error, "Error: no files to compile~n"), halt(1). -spec lc_batch([erl_compile:cmd_line_arg()]) -> no_return(). @@ -203,11 +205,11 @@ make_term(Str) -> case erl_parse:parse_term(Tokens ++ [{dot, 1}]) of {ok, Term} -> Term; {error, {_,_,Reason}} -> - io:format("~s: ~s~n", [Reason, Str]), + io:format(standard_error, "~s: ~s~n", [Reason, Str]), throw(error) end; {error, {_,_,Reason}, _} -> - io:format("~s: ~s~n", [Reason, Str]), + io:format(standard_error, "~s: ~s~n", [Reason, Str]), throw(error) end. @@ -682,7 +684,7 @@ pwd() -> {ok, Str} -> ok = io:format("~ts\n", [fixup_one_bin(Str)]); {error, _} -> - ok = io:format("Cannot determine current directory\n") + ok = io:format(standard_error, "Cannot determine current directory\n") end. -spec cd(Dir) -> 'ok' when @@ -709,7 +711,7 @@ ls(Dir) -> {ok, Entries} -> ls_print(sort(fixup_bin(Entries))); {error,_E} -> - format("Invalid directory\n") + format(standard_error, "Invalid directory\n") end. fixup_one_bin(X) when is_binary(X) -> @@ -799,7 +801,8 @@ appcall(App, M, F, Args) -> case erlang:get_stacktrace() of [{M,F,Args,_}|_] -> Arity = length(Args), - io:format("Call to ~w:~w/~w in application ~w failed.\n", + io:format(standard_error, + "Call to ~w:~w/~w in application ~w failed.\n", [M,F,Arity,App]); Stk -> erlang:raise(error, undef, Stk) diff --git a/lib/stdlib/src/epp.erl b/lib/stdlib/src/epp.erl index ccc14610d74d..08303fed7b3b 100644 --- a/lib/stdlib/src/epp.erl +++ b/lib/stdlib/src/epp.erl @@ -345,7 +345,7 @@ wait_request(St) -> {'EXIT',_,R} -> exit(R); Other -> - io:fwrite("Epp: unknown '~w'\n", [Other]), + io:fwrite(standard_error, "Epp: unknown '~w'\n", [Other]), wait_request(St) end. diff --git a/lib/stdlib/src/erl_compile.erl b/lib/stdlib/src/erl_compile.erl index ff032b129c1b..724cf304cd6e 100644 --- a/lib/stdlib/src/erl_compile.erl +++ b/lib/stdlib/src/erl_compile.erl @@ -78,7 +78,7 @@ compile(List) -> {'EXIT', Pid, {compiler_result, Result}} -> Result; {'EXIT', Pid, Reason} -> - io:format("Runtime error: ~p~n", [Reason]), + io:format(standard_error, "Runtime error: ~p~n", [Reason]), error end. @@ -152,7 +152,8 @@ compile2(Files, Cwd, Opts) -> {[_|_], 1} -> compile3(Files, Cwd, Opts); {[_|_], _N} -> - io:format("Output file name given, but more than one input file.~n"), + io:format(standard_error, + "Output file name given, but more than one input file.~n"), error end. @@ -180,24 +181,24 @@ compile3([], _Cwd, _Options) -> ok. %% Invokes the appropriate compiler, depending on the file extension. compile_file("", Input, _Output, _Options) -> - io:format("File has no extension: ~s~n", [Input]), + io:format(standard_error, "File has no extension: ~s~n", [Input]), error; compile_file(Ext, Input, Output, Options) -> case compiler(Ext) of no -> - io:format("Unknown extension: '~s'\n", [Ext]), + io:format(standard_error, "Unknown extension: '~s'\n", [Ext]), error; {M, F} -> case catch M:F(Input, Output, Options) of ok -> ok; error -> error; {'EXIT',Reason} -> - io:format("Compiler function ~w:~w/3 failed:\n~p~n", + io:format(standard_error, "Compiler function ~w:~w/3 failed:\n~p~n", [M,F,Reason]), error; Other -> - io:format("Compiler function ~w:~w/3 returned:\n~p~n", - [M,F,Other]), + io:format(standard_error, + "Compiler function ~w:~w/3 returned:\n~p~n", [M,F,Other]), error end end. @@ -225,10 +226,10 @@ make_term(Str) -> case erl_parse:parse_term(Tokens ++ [{dot, 1}]) of {ok, Term} -> Term; {error, {_,_,Reason}} -> - io:format("~s: ~s~n", [Reason, Str]), + io:format(standard_error, "~s: ~s~n", [Reason, Str]), throw(error) end; {error, {_,_,Reason}, _} -> - io:format("~s: ~s~n", [Reason, Str]), + io:format(standard_error, "~s: ~s~n", [Reason, Str]), throw(error) end. diff --git a/lib/stdlib/src/escript.erl b/lib/stdlib/src/escript.erl index ad49d899089a..b3abf6fadcc1 100644 --- a/lib/stdlib/src/escript.erl +++ b/lib/stdlib/src/escript.erl @@ -276,16 +276,16 @@ start(EscriptOptions) -> [File|Args] -> parse_and_run(File, Args, EscriptOptions); [] -> - io:format("escript: Missing filename\n", []), + io:format(standard_error, "escript: Missing filename\n", []), my_halt(127) end catch throw:Str -> - io:format("escript: ~s\n", [Str]), + io:format(standard_error, "escript: ~s\n", [Str]), my_halt(127); _:Reason -> - io:format("escript: Internal error: ~p\n", [Reason]), - io:format("~p\n", [erlang:get_stacktrace()]), + io:format(standard_error, "escript: Internal error: ~p\n", [Reason]), + io:format(standard_error, "~p\n", [erlang:get_stacktrace()]), my_halt(127) end. @@ -610,7 +610,7 @@ parse_source(S, File, Fd, StartLine, HeaderSz, CheckOnly) -> ok = file:close(Fd), check_source(S3, CheckOnly); {error, Reason} -> - io:format("escript: ~p\n", [Reason]), + io:format(standard_error, "escript: ~p\n", [Reason]), fatal("Preprocessor error") end. @@ -680,7 +680,7 @@ epp_parse_file2(Epp, S, Forms, Parsed) -> epp_parse_file(Epp, S2, [Form | Forms]); true -> Args = lists:flatten(io_lib:format("illegal mode attribute: ~p", [NewMode])), - io:format("~s:~w ~s\n", [S#state.file,Ln,Args]), + io:format(standard_error, "~s:~w ~s\n", [S#state.file,Ln,Args]), Error = {error,{Ln,erl_parse,Args}}, Nerrs= S#state.n_errors + 1, epp_parse_file(Epp, S2#state{n_errors = Nerrs}, [Error | Forms]) @@ -696,7 +696,7 @@ epp_parse_file2(Epp, S, Forms, Parsed) -> epp_parse_file(Epp, S, [Form | Forms]) end; {error,{Ln,Mod,Args}} = Form -> - io:format("~s:~w: ~s\n", + io:format(standard_error, "~s:~w: ~s\n", [S#state.file,Ln,Mod:format_error(Args)]), epp_parse_file(Epp, S#state{n_errors = S#state.n_errors + 1}, [Form | Forms]); {eof, _LastLine} = Eof -> @@ -766,10 +766,10 @@ report_errors(Errors) -> Errors). list_errors(F, [{Line,Mod,E}|Es]) -> - io:fwrite("~s:~w: ~s\n", [F,Line,Mod:format_error(E)]), + io:fwrite(standard_error, "~s:~w: ~s\n", [F,Line,Mod:format_error(E)]), list_errors(F, Es); list_errors(F, [{Mod,E}|Es]) -> - io:fwrite("~s: ~s\n", [F,Mod:format_error(E)]), + io:fwrite(standard_error, "~s: ~s\n", [F,Mod:format_error(E)]), list_errors(F, Es); list_errors(_F, []) -> ok. @@ -778,7 +778,7 @@ report_warnings(Ws0) -> ({F,Eds}) -> format_message(F, Eds) end, Ws0), Ws = ordsets:from_list(Ws1), - lists:foreach(fun({_,Str}) -> io:put_chars(Str) end, Ws). + lists:foreach(fun({_,Str}) -> io:put_chars(standard_error, Str) end, Ws). format_message(F, [{Line,Mod,E}|Es]) -> M = {{F,Line},io_lib:format("~s:~w: Warning: ~s\n", [F,Line,Mod:format_error(E)])}, @@ -823,7 +823,7 @@ code_handler(Name, Args, Dict, File) -> %% io:format("Calling:~p~n",[{Mod,Name,Args}]), apply(Mod, Name, Args); error -> - io:format("Script does not export ~w/~w\n", [Name,Arity]), + io:format(standard_error, "Script does not export ~w/~w\n", [Name,Arity]), my_halt(127) end end. diff --git a/lib/stdlib/src/shell.erl b/lib/stdlib/src/shell.erl index dc450f0ee6c1..52120a201fc2 100644 --- a/lib/stdlib/src/shell.erl +++ b/lib/stdlib/src/shell.erl @@ -753,7 +753,8 @@ used_records(E) -> {expr, E}. fwrite_severity(Severity, S, As) -> - io:fwrite(<<"~s\n">>, [format_severity(Severity, S, As)]). + io:fwrite(output_stream(Severity), <<"~s\n">>, + [format_severity(Severity, S, As)]). format_severity(Severity, S, As) -> add_severity(Severity, io_lib:fwrite(S, As)). @@ -765,6 +766,10 @@ severity_tag(fatal) -> <<"*** ">>; severity_tag(serious) -> <<"** ">>; severity_tag(benign) -> <<"* ">>. +output_stream(fatal) -> standard_error; +output_stream(serious) -> standard_error; +output_stream(benign) -> standard_io. + restrict_handlers(RShMod, Shell, RT) -> { fun(F,As,Binds) -> local_allowed(F, As, RShMod, Binds, Shell, RT) diff --git a/lib/test_server/src/test_server.erl b/lib/test_server/src/test_server.erl index 51754cb3b494..0ceead6d94cb 100644 --- a/lib/test_server/src/test_server.erl +++ b/lib/test_server/src/test_server.erl @@ -301,7 +301,8 @@ cover_compile({none,_Exclude,Include,Cross}) -> CompileMods = Include++Cross, case length(CompileMods) of 0 -> - io:fwrite("WARNING: No modules to cover compile!\n\n",[]), + io:fwrite(standard_error, + "WARNING: No modules to cover compile!\n\n",[]), cover:start(), % start cover server anyway {ok,[]}; N -> @@ -315,13 +316,15 @@ cover_compile({App,all,Include,Cross}) -> CompileMods = Include++Cross, case length(CompileMods) of 0 -> - io:fwrite("WARNING: No modules to cover compile!\n\n",[]), + io:fwrite(standard_error, + "WARNING: No modules to cover compile!\n\n",[]), cover:start(), % start cover server anyway {ok,[]}; N -> io:fwrite("Cover compiling '~w' (~w files) - " "this may take some time... ",[App,N]), - io:format("\nWARNING: All modules in \'~w\' are excluded\n" + io:format(standard_error, + "\nWARNING: All modules in \'~w\' are excluded\n" "Only cover compiling modules in include list " "and the modules\nin the cross cover file:\n" "~p\n", [App,CompileMods]), @@ -334,14 +337,16 @@ cover_compile({App,Exclude,Include,Cross}) -> {error,bad_name} -> case Include++Cross of [] -> - io:format("\nWARNING: Can't find lib_dir for \'~w\'\n" + io:format(standard_error, + "\nWARNING: Can't find lib_dir for \'~w\'\n" "Not cover compiling!\n\n",[App]), {error,application_not_found}; CompileMods -> io:fwrite("Cover compiling '~w' (~w files) - " "this may take some time... ", [App,length(CompileMods)]), - io:format("\nWARNING: Can't find lib_dir for \'~w\'\n" + io:format(standard_error, + "\nWARNING: Can't find lib_dir for \'~w\'\n" "Only cover compiling modules in include list: " "~p\n", [App,Include]), do_cover_compile(CompileMods), @@ -356,7 +361,8 @@ cover_compile({App,Exclude,Include,Cross}) -> CompileMods = AnalyseMods ++ Cross, case length(CompileMods) of 0 -> - io:fwrite("WARNING: No modules to cover compile!\n\n",[]), + io:fwrite(standard_error, + "WARNING: No modules to cover compile!\n\n",[]), cover:start(), % start cover server anyway {ok,[]}; N -> @@ -388,8 +394,8 @@ do_cover_compile1([M|Rest]) -> {ok,_} -> ok; Error -> - io:fwrite("\nWARNING: Could not cover compile ~w: ~p\n", - [M,Error]) + io:fwrite(standard_error, + "\nWARNING: Could not cover compile ~w: ~p\n", [M,Error]) end, code:stick_mod(M), do_cover_compile1(Rest); @@ -398,7 +404,8 @@ do_cover_compile1([M|Rest]) -> {module,_} -> do_cover_compile1([M|Rest]); Error -> - io:fwrite("\nWARNING: Could not load ~w: ~p\n",[M,Error]), + io:fwrite(standard_error, + "\nWARNING: Could not load ~w: ~p\n",[M,Error]), do_cover_compile1(Rest) end; {false,_} -> @@ -406,8 +413,8 @@ do_cover_compile1([M|Rest]) -> {ok,_} -> ok; Error -> - io:fwrite("\nWARNING: Could not cover compile ~w: ~p\n", - [M,Error]) + io:fwrite(standard_error, + "\nWARNING: Could not cover compile ~w: ~p\n", [M,Error]) end, do_cover_compile1(Rest) end; @@ -477,8 +484,8 @@ cover_analyse(Analyse,Modules) -> {ok,{M,{Cov,NotCov}}} -> {M,{Cov,NotCov,DetailsFun(M)}}; Err -> - io:fwrite("WARNING: Analysis failed for ~w. Reason: ~p\n", - [M,Err]), + io:fwrite(standard_error, + "WARNING: Analysis failed for ~w. Reason: ~p\n", [M,Err]), {M,Err} end end, Modules), diff --git a/lib/test_server/src/test_server_ctrl.erl b/lib/test_server/src/test_server_ctrl.erl index 3432b3bc8e7a..355e5172c611 100644 --- a/lib/test_server/src/test_server_ctrl.erl +++ b/lib/test_server/src/test_server_ctrl.erl @@ -339,7 +339,7 @@ parse_cmd_line(['SPEC',Spec|Cmds], SpecList, Names, Param, Trc, Cov, TCCB) -> parse_cmd_line(Cmds, TermList++SpecList, [Name|Names], Param, Trc, Cov, TCCB); {error,Reason} -> - io:format("Can't open ~s: ~p\n", + io:format(standard_error, "Can't open ~s: ~p\n", [cast_to_list(Spec), file:format_error(Reason)]), parse_cmd_line(Cmds, SpecList, Names, Param, Trc, Cov, TCCB) end; @@ -370,9 +370,9 @@ parse_cmd_line(['COVER',App,CF,Analyse|Cmds], SpecList, Names, Param, Trc, _Cov, parse_cmd_line(['TESTCASE_CALLBACK',Mod,Func|Cmds], SpecList, Names, Param, Trc, Cov, _) -> parse_cmd_line(Cmds, SpecList, Names, Param, Trc, Cov, {Mod,Func}); parse_cmd_line([Obj|_Cmds], _SpecList, _Names, _Param, _Trc, _Cov, _TCCB) -> - io:format("~p: Bad argument: ~p\n", [?MODULE,Obj]), - io:format(" Use the `ts' module to start tests.\n", []), - io:format(" (If you ARE using `ts', there is a bug in `ts'.)\n", []), + io:format(standard_error, "~p: Bad argument: ~p\n", [?MODULE,Obj]), + io:format(standard_error, " Use the `ts' module to start tests.\n", []), + io:format(standard_error, " (If you ARE using `ts', there is a bug in `ts'.)\n", []), halt(1); parse_cmd_line([], SpecList, Names, Param, Trc, Cov, TCCB) -> NameList = lists:reverse(Names, [suite]), @@ -1207,9 +1207,9 @@ handle_info({'EXIT',Pid,Reason}, State) -> normal -> fine; killed -> - io:format("Suite ~s was killed\n", [Name]); + io:format(standard_error, "Suite ~s was killed\n", [Name]); _Other -> - io:format("Suite ~s was killed with reason ~p\n", + io:format(standard_error, "Suite ~s was killed with reason ~p\n", [Name,Reason]) end, State2 = State#state{jobs=NewJobs}, @@ -1253,7 +1253,8 @@ handle_info({tcp,_MainSock,<<1,Request/binary>>}, State) -> %% The local job proc will soon be killed by the closed socket or %% because the job is finished. Then the above clause ('EXIT') will %% handle the problem. - io:format("Suite ~s was killed on remote target with reason" + io:format(standard_error, + "Suite ~s was killed on remote target with reason" " ~p\n", [Name,Reason]); _ -> ignore @@ -1454,7 +1455,7 @@ do_spec(SpecName, TimetrapSpec) when is_list(SpecName) -> {ok,TermList} -> do_spec_list(TermList,TimetrapSpec); {error,Reason} -> - io:format("Can't open ~s: ~p\n", [SpecName,Reason]), + io:format(standard_error, "Can't open ~s: ~p\n", [SpecName,Reason]), {error,{cant_open_spec,Reason}} end. @@ -1537,7 +1538,7 @@ do_spec_terms([{require_nodenames,NumNames}|Terms], TopCases, SkipList, Config) do_spec_terms(Terms, TopCases, SkipList, update_config(Config, {nodenames,NodeNames})); do_spec_terms([Other|Terms], TopCases, SkipList, Config) -> - io:format("** WARNING: Spec file contains unknown directive ~p\n", + io:format(standard_error, "** WARNING: Spec file contains unknown directive ~p\n", [Other]), do_spec_terms(Terms, TopCases, SkipList, Config). @@ -2087,7 +2088,7 @@ copy_html_file(Src, DestDir) -> {ok,Bin} -> ok = file:write_file(Dest, Bin); {error,_Reason} -> - io:format("File ~p: read failed\n", [Src]) + io:format(standard_error, "File ~p: read failed\n", [Src]) end. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -3842,7 +3843,7 @@ maybe_send_beam_and_datadir(Mod) -> send_beam_and_datadir(Mod, JobSock) -> case code:which(Mod) of non_existing -> - io:format("** WARNING: Suite ~w could not be found on host\n", + io:format(standard_error, "** WARNING: Suite ~w could not be found on host\n", [Mod]); BeamFile -> send_beam(JobSock, Mod, BeamFile) @@ -4863,7 +4864,7 @@ collect_files(Dir, Pattern, St) -> Wc = filename:join([Dir1,Pattern++code:objfile_extension()]), case catch filelib:wildcard(Wc) of {'EXIT', Reason} -> - io:format("Could not collect files: ~p~n", [Reason]), + io:format(standard_error, "Could not collect files: ~p~n", [Reason]), {error,{collect_fail,Dir,Pattern}}; Mods0 -> Mods = [{path_to_module(Mod),all} || Mod <- lists:sort(Mods0)], @@ -5547,7 +5548,8 @@ write_coverlog_header(CoverLog) -> "link=\"blue\" vlink=\"purple\" alink=\"red\">", [?MODULE]) of {'EXIT',Reason} -> - io:format("\n\nERROR: Could not write normal heading in coverlog.\n" + io:format(standard_error, + "\n\nERROR: Could not write normal heading in coverlog.\n" "CoverLog: ~w\n" "Reason: ~p\n", [CoverLog,Reason]), diff --git a/lib/test_server/src/ts_reports.erl b/lib/test_server/src/ts_reports.erl index f981a77ae4fa..fc9ed23caf94 100644 --- a/lib/test_server/src/ts_reports.erl +++ b/lib/test_server/src/ts_reports.erl @@ -47,7 +47,8 @@ make_master_index1([Dir|Rest], Result) -> NewResult = case catch read_variables(Dir) of {'EXIT',{{bad_installation,Reason},_}} -> - io:put_chars("Failed to read " ++ filename:join(Dir,?variables)++ + io:put_chars(standard_error, + "Failed to read " ++ filename:join(Dir,?variables)++ ": " ++ Reason ++ " - Ignoring this directory\n"), Result; Vars -> @@ -154,18 +155,19 @@ make_index(Dir, Vars, IncludeLast) -> io:put_chars("Updating " ++ IndexName ++ "... "), case catch make_index1(Dir, IndexName, Vars, IncludeLast) of {'EXIT', Reason} -> - io:put_chars("CRASHED!\n"), - io:format("~p~n", [Reason]), + io:put_chars(standard_error, "CRASHED!\n"), + io:format(standard_error, "~p~n", [Reason]), {error, Reason}; {error, Reason} -> - io:put_chars("FAILED\n"), - io:format("~p~n", [Reason]), + io:put_chars(standard_error, "FAILED\n"), + io:format(standard_error, "~p~n", [Reason]), {error, Reason}; {ok, Summary} -> io:put_chars("done\n"), {ok, Summary}; Err -> - io:format("Unknown internal error. Please report.\n(Err: ~p, ID: 1)", + io:format(standard_error, + "Unknown internal error. Please report.\n(Err: ~p, ID: 1)", [Err]), {error, Err} end. diff --git a/lib/test_server/src/ts_run.erl b/lib/test_server/src/ts_run.erl index 885a3c9b96be..10672c882d5a 100644 --- a/lib/test_server/src/ts_run.erl +++ b/lib/test_server/src/ts_run.erl @@ -269,7 +269,7 @@ tricky_print_data(Port) -> {ok,Names} -> case is_testnode_dead(Names) of true -> - io:put_chars("WARNING: No EOF, but " + io:put_chars(standard_error, "WARNING: No EOF, but " "test_server node is down!\n"); false -> tricky_print_data(Port) @@ -311,12 +311,12 @@ run_interactive(Vars, _Spec, State) -> start_xterm(Command) -> case os:find_executable("xterm") of false -> - io:format("The `xterm' program was not found.\n"), + io:format(standard_error, "The `xterm' program was not found.\n"), {error, no_xterm}; _Xterm -> case os:getenv("DISPLAY") of false -> - io:format("DISPLAY is not set.\n"), + io:format(standard_error, "DISPLAY is not set.\n"), {error, display_not_set}; Display -> io:format("Starting xterm (DISPLAY=~s)...\n", @@ -350,7 +350,7 @@ make_common_test_args(Args0, Options, _Vars) -> Cover = case lists:keysearch(cover,1,Options) of {value,{cover, App, none, _Analyse}} -> - io:format("No cover file found for ~p~n",[App]), + io:format(standard_error, "No cover file found for ~p~n",[App]), []; {value,{cover,_App,File,_Analyse}} -> [{cover,to_list(File)}]; diff --git a/lib/tools/src/cover.erl b/lib/tools/src/cover.erl index e21bd1b88cc3..c2bbc3f53fb7 100644 --- a/lib/tools/src/cover.erl +++ b/lib/tools/src/cover.erl @@ -585,7 +585,7 @@ main_process_loop(State) -> link(RPid), [Node|Acc]; Error -> - io:format("Could not start cover on ~w: ~p\n", + io:format(standard_error, "Could not start cover on ~w: ~p\n", [Node,Error]), Acc end @@ -857,7 +857,7 @@ remote_process_loop(State) -> remote_process_loop(State); M -> - io:format("WARNING: remote cover_server received\n~p\n",[M]), + io:format(standard_error, "WARNING: remote cover_server received\n~p\n",[M]), case M of {From,_} -> case is_from(From) of @@ -1148,7 +1148,8 @@ add_imported(Module, File, ImportFile, Imported) -> add_imported(M, F1, ImportFile, [{M,_F2,ImportFiles}|Imported], Acc) -> case lists:member(ImportFile,ImportFiles) of true -> - io:fwrite("WARNING: Module ~w already imported from ~p~n" + io:fwrite(standard_error, + "WARNING: Module ~w already imported from ~p~n" "Not importing again!~n",[M,ImportFile]), dont_import; false -> @@ -1165,7 +1166,8 @@ add_imported(M, F, ImportFile, [], Acc) -> remove_imported(Module,Imported) -> case lists:keysearch(Module,1,Imported) of {value,{Module,_,ImportFiles}} -> - io:fwrite("WARNING: Deleting data for module ~w imported from~n" + io:fwrite(standard_error, + "WARNING: Deleting data for module ~w imported from~n" "~p~n",[Module,ImportFiles]), lists:keydelete(Module,1,Imported); false -> diff --git a/lib/tools/src/make.erl b/lib/tools/src/make.erl index 5cc8d47faaae..c34511a20910 100644 --- a/lib/tools/src/make.erl +++ b/lib/tools/src/make.erl @@ -90,7 +90,8 @@ read_emakefile(Emakefile,Opts) -> Mods = [filename:rootname(F) || F <- filelib:wildcard("*.erl")], [{Mods, Opts}]; {error,Other} -> - io:format("make: Trouble reading 'Emakefile':~n~p~n",[Other]), + io:format(standard_error, "make: Trouble reading 'Emakefile':~n~p~n", + [Other]), error end. @@ -145,7 +146,8 @@ get_opts_from_emakefile(Mods,Emakefile,Opts) -> {error,enoent} -> [{Mods, Opts}]; {error,Other} -> - io:format("make: Trouble reading 'Emakefile':~n~p~n",[Other]), + io:format(standard_error, "make: Trouble reading 'Emakefile':~n~p~n", + [Other]), error end. diff --git a/lib/tools/src/xref_base.erl b/lib/tools/src/xref_base.erl index 93f0e9c0c8c1..d79cb0cc0066 100644 --- a/lib/tools/src/xref_base.erl +++ b/lib/tools/src/xref_base.erl @@ -1506,7 +1506,8 @@ do_variables(State) -> _Else -> {[Name | P], U} end; ({{tmp, V}, _}, A) -> - io:format("Bug in ~p: temporary ~p~n", [?MODULE, V]), A; + io:format(standard_error, "Bug in ~p: temporary ~p~n", [?MODULE, V]), + A; (_V, A) -> A end, {U,P} = foldl(Fun, {[],[]}, dict:to_list(State#xref.variables)), @@ -1772,9 +1773,9 @@ message(true, What, Arg) -> no_debug_info -> io:format("Skipping ~s (no debug information)~n", Arg); unresolved_summary1 -> - io:format("~p: 1 unresolved call~n", Arg); + io:format(standard_error, "~p: 1 unresolved call~n", Arg); unresolved_summary -> - io:format("~p: ~p unresolved calls~n", Arg); + io:format(standard_error, "~p: ~p unresolved calls~n", Arg); jam -> io:format("Skipping ~s (probably JAM file)~n", [Arg]); unreadable -> @@ -1792,9 +1793,9 @@ message(true, What, Arg) -> done -> io:format("done~n", Arg); error -> - io:format("error~n", Arg); + io:format(standard_error, "error~n", Arg); Else -> - io:format("~p~n", [{Else,Arg}]) + io:format(standard_error, "~p~n", [{Else,Arg}]) end; message(_, _, _) -> true.