diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2018-10-20 10:40:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-20 10:40:03 -0400 |
commit | ac69c3898609c5ff55c063c6ac12c6c201ab0cc0 (patch) | |
tree | 70871e671cfb0ab04563566a7167110cebb7f850 /src | |
parent | 384d8cccce85de1474d65272ef8f87767ac5bfc4 (diff) | |
parent | bf039fa4c4d7ea9dc0d9a842f2ab2aa93a9c61d3 (diff) |
Merge pull request #1920 from ferd/fallback-log
Fallback when logging isn't initialized
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_log.erl | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/rebar_log.erl b/src/rebar_log.erl index 9150346..7fc2312 100644 --- a/src/rebar_log.erl +++ b/src/rebar_log.erl @@ -93,11 +93,18 @@ get_level() -> end. log(Level = error, Str, Args) -> - {ok, LogState} = application:get_env(rebar, log), - ec_cmd_log:Level(LogState, lists:flatten(cf:format("~!^~ts~n", [Str])), Args); + case application:get_env(rebar, log) of + {ok, LogState} -> + NewStr = lists:flatten(cf:format("~!^~ts~n", [Str])), + ec_cmd_log:Level( LogState, NewStr, Args); + undefined -> % fallback + io:format(standard_error, Str++"~n", Args) + end; log(Level, Str, Args) -> - {ok, LogState} = application:get_env(rebar, log), - ec_cmd_log:Level(LogState, Str++"~n", Args). + case application:get_env(rebar, log) of + {ok, LogState} -> ec_cmd_log:Level(LogState, Str++"~n", Args); + undefined -> io:format(Str++"~n", Args) + end. crashdump(Str, Args) -> crashdump("rebar3.crashdump", Str, Args). |