diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2016-06-10 20:25:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-10 20:25:59 -0400 |
commit | 979bb18b279d54a59a1ed72a5965b12ec3ac311e (patch) | |
tree | 4174c64cc9fa47ba06a19874a5ad08c74766088c /src/rebar_log.erl | |
parent | e6d64858c5b6f951d20975f150b45ebdc401da2e (diff) | |
parent | 5945251fc032465b1eb609fee16efa52a9854a5a (diff) |
Merge pull request #1080 from project-fifo/crashdump
Write rebar3.crashdump on errors
Diffstat (limited to 'src/rebar_log.erl')
-rw-r--r-- | src/rebar_log.erl | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/rebar_log.erl b/src/rebar_log.erl index 23ae81e..b1a70c2 100644 --- a/src/rebar_log.erl +++ b/src/rebar_log.erl @@ -27,6 +27,7 @@ -module(rebar_log). -export([init/2, + crashdump/2, set_level/1, get_level/0, error_level/0, @@ -73,6 +74,7 @@ init(Caller, Verbosity) -> ?DEBUG_LEVEL -> debug end, Intensity = intensity(), + application:set_env(rebar, log_caller, Caller), Log = ec_cmd_log:new(Level, Caller, Intensity), set_level(valid_level(Verbosity)), application:set_env(rebar, log, Log). @@ -95,6 +97,16 @@ log(Level, Str, Args) -> {ok, LogState} = application:get_env(rebar, log), ec_cmd_log:Level(LogState, Str++"~n", Args). +crashdump(Str, Args) -> + crashdump("rebar3.crashdump", Str, Args). +crashdump(File, Str, Args) -> + case application:get_env(rebar, log_caller) of + {ok, api} -> + ok; + _ -> + file:write_file(File, io_lib:fwrite(Str, Args)) + end. + error_level() -> ?ERROR_LEVEL. default_level() -> ?INFO_LEVEL. |