Skip to content

Commit

Permalink
Merge pull request #2860 from richcarl/fix-log-config
Browse files Browse the repository at this point in the history
Make log_level entry in rebar.app work again
  • Loading branch information
ferd authored Feb 20, 2024
2 parents 8207d82 + 536c2c9 commit 4393095
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/rebar/src/rebar.app.src.script
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
]},
{env, [
%% Default log level
{log_level, warn},
{log_level, info},

{resources, [{git, rebar_git_resource},
{git_subdir, rebar_git_subdir_resource},
Expand Down
7 changes: 6 additions & 1 deletion apps/rebar/src/rebar3.erl
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,12 @@ log_level() ->
Di when Di == false; Di == "" ->
case os:getenv("DEBUG") of
D when D == false; D == "" ->
rebar_log:default_level();
try
{ok, L} = application:get_env(rebar, log_level),
rebar_log:atom_to_level(L)
catch
_:_ -> rebar_log:default_level()
end;
_ ->
rebar_log:debug_level()
end;
Expand Down
10 changes: 10 additions & 0 deletions apps/rebar/src/rebar_log.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
default_level/0,
debug_level/0,
diagnostic_level/0,
atom_to_level/1,
intensity/0,
log/3,
is_verbose/1,
Expand Down Expand Up @@ -143,6 +144,15 @@ is_verbose(State) ->
valid_level(Level) ->
erlang:max(?ERROR_LEVEL, erlang:min(Level, ?DIAGNOSTIC_LEVEL)).

atom_to_level(Level) ->
case Level of
error -> ?ERROR_LEVEL;
warn -> ?WARN_LEVEL;
info -> ?INFO_LEVEL;
debug -> ?DEBUG_LEVEL;
diagnostic -> ?DIAGNOSTIC_LEVEL
end.

%% ===================================================================
%% Internal functions
%% ===================================================================
Expand Down

0 comments on commit 4393095

Please sign in to comment.