ソースを参照

Make sure not to dump in api mode

pull/1080/head
Heinz N. Gies 9年前
コミット
5945251fc0
4個のファイルの変更18行の追加5行の削除
  1. +1
    -0
      src/rebar.hrl
  2. +3
    -3
      src/rebar3.erl
  3. +12
    -0
      src/rebar_log.erl
  4. +2
    -2
      src/rebar_state.erl

+ 1
- 0
src/rebar.hrl ファイルの表示

@ -10,6 +10,7 @@
-define(INFO(Str, Args), rebar_log:log(info, Str, Args)).
-define(WARN(Str, Args), rebar_log:log(warn, Str, Args)).
-define(ERROR(Str, Args), rebar_log:log(error, Str, Args)).
-define(CRASHDUMP(Str, Args), rebar_log:crashdump(Str, Args)).
-define(FMT(Str, Args), lists:flatten(io_lib:format(Str, Args))).

+ 3
- 3
src/rebar3.erl ファイルの表示

@ -265,8 +265,8 @@ handle_error({error, rebar_abort}) ->
handle_error({error, {Module, Reason}}) ->
case code:which(Module) of
non_existing ->
file:write_file("rebar3.crashdump", io_lib:fwrite("~p: ~p~n~p~n~n", [Module, Reason, erlang:get_stacktrace()])),
?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace rebar3.crashdump", []),
?CRASHDUMP("~p: ~p~n~p~n~n", [Module, Reason, erlang:get_stacktrace()]),
?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to stacktrace or consult rebar3.crashdump", []),
?DEBUG("Uncaught error: ~p ~p", [Module, Reason]),
?INFO("When submitting a bug report, please include the output of `rebar3 report \"your command\"`", []);
_ ->
@ -279,7 +279,7 @@ handle_error({error, Error}) when is_list(Error) ->
handle_error(Error) ->
%% Nothing should percolate up from rebar_core;
%% Dump this error to console
file:write_file("rebar3.crashdump", io_lib:fwrite("Error: ~p~n~p~n~n", [Error, erlang:get_stacktrace()])),
?CRASHDUMP("Error: ~p~n~p~n~n", [Error, erlang:get_stacktrace()]),
?ERROR("Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump", []),
?DEBUG("Uncaught error: ~p", [Error]),
case erlang:get_stacktrace() of

+ 12
- 0
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.

+ 2
- 2
src/rebar_state.erl ファイルの表示

@ -417,8 +417,8 @@ create_logic_providers(ProviderModules, State0) ->
catch
C:T ->
?DEBUG("~p: ~p ~p", [C, T, erlang:get_stacktrace()]),
file:write_file("rebar3.crashdump", io_lib:fwrite("~p: ~p~n~p~n~n~p", [C, T, erlang:get_stacktrace(), State0])),
throw({error, "Failed creating providers. Run with DEBUG=1 for stacktrace rebar3.crashdump."})
?CRASHDUMP("~p: ~p~n~p~n~n~p", [C, T, erlang:get_stacktrace(), State0]),
throw({error, "Failed creating providers. Run with DEBUG=1 for stacktrace or consult rebar3.crashdump."})
end.
to_list(#state_t{} = State) ->

読み込み中…
キャンセル
保存