rewrite from lager
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

35 行
1.3 KiB

4年前
4年前
4年前
  1. %% @doc This test is named zzzz_gh280_crash because it has to be run first and tests are run in
  2. %% reverse alphabetical order.
  3. %%
  4. %% The problem we are attempting to detect here is when log_mf_h is installed as a handler for error_logger
  5. %% and lager starts up to replace the current handlers with its own. This causes a start up crash because
  6. %% OTP error logging modules do not have any notion of a lager-style log level.
  7. -module(zzzz_gh280_crash).
  8. -include_lib("eunit/include/eunit.hrl").
  9. gh280_crash_test() ->
  10. {timeout, 30, fun() -> gh280_impl() end}.
  11. gh280_impl() ->
  12. application:stop(lager),
  13. application:stop(goldrush),
  14. error_logger:tty(false),
  15. %% see https://github.com/erlang/otp/blob/maint/lib/stdlib/src/log_mf_h.erl#L81
  16. %% for an explanation of the init arguments to log_mf_h
  17. ok = gen_event:add_sup_handler(error_logger, log_mf_h, log_mf_h:init("/tmp", 10000, 5)),
  18. eRum:start(),
  19. Result = receive
  20. {gen_event_EXIT, log_mf_h, normal} ->
  21. true;
  22. {gen_event_EXIT, Handler, Reason} ->
  23. {Handler, Reason};
  24. X ->
  25. X
  26. after 10000 ->
  27. timeout
  28. end,
  29. ?assert(Result),
  30. application:stop(lager),
  31. application:stop(goldrush).