File 0003-Confirm-lack-of-regressions-on-new-logger-in-shell.patch of Package rebar

From b34cafa8e332f2f17c2f8dd0df28409c12b4e30a Mon Sep 17 00:00:00 2001
From: Led <ledest@gmail.com>
Date: Mon, 24 Aug 2020 16:44:40 +0300
Subject: [PATCH] Confirm lack of regressions on new logger in shell

---
 rebar.config        |  1 +
 src/rebar_shell.erl | 22 ++++++++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/rebar.config b/rebar.config
index eda5a2c..2884843 100644
--- a/rebar.config
+++ b/rebar.config
@@ -31,6 +31,7 @@
       - (\"diameter_dict_util\":\"format_error\"/\"1\")
       - (\"diameter_dict_util\":\"parse\"/\"2\")
       - (\"erlang\":\"timestamp\"/\"0\")
+      - (\"error_logger\":\"swap_handler\"/\"1\")
       - (\"rebar_rnd\":\"seed\"/\"1\")
       - (\"rebar_rnd\":\"uniform\"/\"0\"))",
          []}]}.
diff --git a/src/rebar_shell.erl b/src/rebar_shell.erl
index 0220a79..b7dd4b7 100644
--- a/src/rebar_shell.erl
+++ b/src/rebar_shell.erl
@@ -55,12 +55,22 @@ shell(_Config, _AppFile) ->
     %% set any process that had a reference to the old user's group leader to the
     %% new user process
     _ = [erlang:group_leader(whereis(user), Pid) || Pid <- NeedsUpdate],
-    %% enable error_logger's tty output
-    ok = 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
-    ok = remove_error_handler(3),
+    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,
     %% this call never returns (until user quits shell)
     timer:sleep(infinity).
 
-- 
2.26.2

openSUSE Build Service is sponsored by