diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2018-05-03 18:14:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-03 18:14:11 -0400 |
commit | 048dfad1e8e05aead68cdd062653d8f51d2eaf88 (patch) | |
tree | 5157ad3d51aa3765df04a226206441a07e95974f /src/rebar_prv_shell.erl | |
parent | a908284b112ff77dbf0ae9b9f946bc7b739faf29 (diff) | |
parent | e321ca64981504f10a3be1715ce5d94c3cd10ae7 (diff) |
Merge pull request #1773 from ferd/otp-21-stacktrace-compat
Work around OTP-21 deprecation of get_stacktrace() and other incompatible changes
Diffstat (limited to 'src/rebar_prv_shell.erl')
-rw-r--r-- | src/rebar_prv_shell.erl | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/rebar_prv_shell.erl b/src/rebar_prv_shell.erl index 2c48083..9a320ad 100644 --- a/src/rebar_prv_shell.erl +++ b/src/rebar_prv_shell.erl @@ -201,21 +201,28 @@ rewrite_leaders(OldUser, NewUser) -> lists:member(proplists:get_value(group_leader, erlang:process_info(Pid)), OldMasters)], try - %% enable error_logger's tty output - error_logger:swap_handler(tty), - %% disable the simple error_logger (which may have been added multiple - %% times). removes at most the error_logger added by init and the - %% error_logger added by the tty handler - remove_error_handler(3), - %% reset the tty handler once more for remote shells - error_logger:swap_handler(tty) + case erlang:function_exported(logger, module_info, 0) of + false -> + %% Old style logger had a lock-up issue and other problems related + %% to group leader handling. + %% enable error_logger's tty output + error_logger:swap_handler(tty), + %% disable the simple error_logger (which may have been added + %% multiple times). removes at most the error_logger added by + %% init and the error_logger added by the tty handler + remove_error_handler(3), + %% reset the tty handler once more for remote shells + error_logger:swap_handler(tty); + true -> + %% This is no longer a problem with the logger interface + ok + end catch - E:R -> % may fail with custom loggers - ?DEBUG("Logger changes failed for ~p:~p (~p)", [E,R,erlang:get_stacktrace()]), + ?WITH_STACKTRACE(E,R,S) % may fail with custom loggers + ?DEBUG("Logger changes failed for ~p:~p (~p)", [E,R,S]), hope_for_best end. - setup_paths(State) -> %% Add deps to path code:add_pathsa(rebar_state:code_paths(State, all_deps)), @@ -235,9 +242,9 @@ maybe_run_script(State) -> File = filename:absname(RelFile), try run_script_file(File) catch - C:E -> + ?WITH_STACKTRACE(C,E,S) ?ABORT("Couldn't run shell escript ~p - ~p:~p~nStack: ~p", - [File, C, E, erlang:get_stacktrace()]) + [File, C, E, S]) end end. |