Просмотр исходного кода

Merge pull request #282 from basho/test/mra/gh280

Add test case and fix for #280

Reviewed-by: javajolt
pull/294/head
Bishop Bors 9 лет назад
Родитель
Сommit
ca280a2a02
2 измененных файлов: 37 добавлений и 0 удалений
  1. +4
    -0
      src/lager.erl
  2. +33
    -0
      test/zzzz_gh280_crash.erl

+ 4
- 0
src/lager.erl Просмотреть файл

@ -469,6 +469,10 @@ add_trace_to_loglevel_config(Trace, Sink) ->
end.
%% @doc recalculate min log level
update_loglevel_config(error_logger) ->
%% Not a sink under our control, part of the Erlang logging
%% utility that error_logger_lager_h attaches to
true;
update_loglevel_config(Sink) ->
{_, Traces} = lager_config:get({Sink, loglevel}, {ignore_me, []}),
MinLog = minimum_loglevel(get_loglevels(Sink)),

+ 33
- 0
test/zzzz_gh280_crash.erl Просмотреть файл

@ -0,0 +1,33 @@
%% @doc This test is named zzzz_gh280_crash because it has to be run first and tests are run in
%% reverse alphabetical order.
%%
%% The problem we are attempting to detect here is when log_mf_h is installed as a handler for error_logger
%% and lager starts up to replace the current handlers with its own. This causes a start up crash because
%% OTP error logging modules do not have any notion of a lager-style log level.
-module(zzzz_gh280_crash).
-compile(export_all).
-include_lib("eunit/include/eunit.hrl").
gh280_crash_test() ->
application:stop(lager),
application:stop(goldrush),
error_logger:tty(false),
%% see https://github.com/erlang/otp/blob/maint/lib/stdlib/src/log_mf_h.erl#L81
%% for an explanation of the init arguments to log_mf_h
ok = gen_event:add_sup_handler(error_logger, log_mf_h, log_mf_h:init("/tmp", 10000, 5)),
lager:start(),
Result = receive
{gen_event_EXIT,log_mf_h,normal} ->
true;
{gen_event_EXIT,Handler,Reason} ->
{Handler,Reason};
X ->
X
after 1000 ->
timeout
end,
?assert(Result),
application:stop(lager),
application:stop(goldrush).

Загрузка…
Отмена
Сохранить