build(update_appup): red color for error logs

This commit is contained in:
Zaiming (Stone) Shi 2022-09-20 20:28:30 +02:00
parent 9d99bf8b91
commit 9d00b5b0d6
1 changed files with 12 additions and 6 deletions

View File

@ -3,6 +3,9 @@
-mode(compile). -mode(compile).
-define(RED, "\e[31m").
-define(RESET, "\e[39m").
usage() -> usage() ->
"A script that fills in boilerplate for appup files. "A script that fills in boilerplate for appup files.
@ -109,7 +112,7 @@ changes, supervisor changes, process restarts and so on. Also the load order of
the beam files might need updating.~n"), the beam files might need updating.~n"),
halt(0); halt(0);
warn_and_exit(false) -> warn_and_exit(false) ->
log("~nERROR: Incomplete appups found. Please inspect the output for more details.~n"), logerr("Incomplete appups found. Please inspect the output for more details.~n", []),
halt(1). halt(1).
prepare(Baseline, Options = #{make_command := MakeCommand, beams_dir := BeamDir}) -> prepare(Baseline, Options = #{make_command := MakeCommand, beams_dir := BeamDir}) ->
@ -474,7 +477,7 @@ check_appup(App, Upgrade, Downgrade, OldUpgrade, OldDowngrade) ->
ok; ok;
{diffs, Diffs} -> {diffs, Diffs} ->
set_invalid(), set_invalid(),
log("ERROR: Appup file for '~p' is not complete.~n" logerr("Appup file for '~p' is not complete.~n"
"Missing:~100p~n", [App, Diffs]), "Missing:~100p~n", [App, Diffs]),
notok notok
end. end.
@ -494,7 +497,7 @@ render_appup(App, File, Up, Down) ->
do_render_appup(File, Up, Down); do_render_appup(File, Up, Down);
{error, enoent} when IsCheck -> {error, enoent} when IsCheck ->
%% failed to read old file, exit %% failed to read old file, exit
log("ERROR: ~s is missing", [File]), logerr("~s is missing", [File]),
set_invalid() set_invalid()
end. end.
@ -580,7 +583,7 @@ diff_app(UpOrDown, App,
case UpOrDown =:= up of case UpOrDown =:= up of
true -> true ->
%% only log for the upgrade case because it would be the same result %% only log for the upgrade case because it would be the same result
log("ERROR: Application '~p' contains changes, but its version is not updated. ~s", logerr("Application '~p' contains changes, but its version is not updated. ~s",
[App, format_changes(Changes)]); [App, format_changes(Changes)]);
false -> false ->
ok ok
@ -723,5 +726,8 @@ log(Msg) ->
log(Msg, Args) -> log(Msg, Args) ->
io:format(standard_error, Msg, Args). io:format(standard_error, Msg, Args).
logerr(Msg, Args) ->
io:format(standard_error, ?RED ++ "ERROR: "++ Msg ++ ?RESET, Args).
otp_standard_apps() -> otp_standard_apps() ->
[ssl, mnesia, kernel, asn1, stdlib]. [ssl, mnesia, kernel, asn1, stdlib].