Skip to content

Commit

Permalink
Merge pull request #2513 from max-au/max-au/shell-boot-message
Browse files Browse the repository at this point in the history
rebar3 shell: implement various modes to print "booted" message
  • Loading branch information
ferd authored Mar 16, 2021
2 parents dd9b8b1 + eb086dd commit ab5c342
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/rebar_prv_shell.erl
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,10 @@ maybe_boot_apps(State) ->
%% load apps, then check config, then boot them.
load_apps(Apps),
ok = reread_config(Apps, State),
boot_apps(Apps)
ShellOpts = rebar_state:get(State, shell, []),
BootLogLevel = debug_get_value(log, ShellOpts, info,
"Found boot log verbosity mode from config."),
boot_apps(Apps, BootLogLevel)
end.

simulate_proc_lib() ->
Expand Down Expand Up @@ -442,16 +445,20 @@ reread_config(AppsToStart, State) ->
ok
end.

boot_apps(Apps) ->
boot_apps(Apps, BootLogLevel) ->
Normalized = normalize_boot_apps(Apps),
Res = [application:ensure_all_started(App) || App <- Normalized],
_ = [?INFO("Booted ~p", [App])
|| {ok, Booted} <- Res,
App <- Booted],
print_booted([App || {ok, Booted} <- Res, App <- Booted], BootLogLevel),
%% errors are not suppressed
_ = [?ERROR("Failed to boot ~p for reason ~p", [App, Reason])
|| {error, {App, Reason}} <- Res],
ok.

print_booted(Booted, debug) ->
_ = [?DEBUG("Booted ~p", [App]) || App <- Booted];
print_booted(Booted, info) ->
_ = [?INFO("Booted ~p", [App]) || App <- Booted].

normalize_load_apps([]) -> [];
normalize_load_apps([{_App, none} | T]) -> normalize_load_apps(T);
normalize_load_apps([{App, _} | T]) -> [App | normalize_load_apps(T)];
Expand Down

0 comments on commit ab5c342

Please sign in to comment.