|
|
@ -417,12 +417,12 @@ lager_test_() -> |
|
|
|
eRum:debug("this message will be ignored"), |
|
|
|
?assertEqual(0, count()), |
|
|
|
?assertEqual(0, count_ignored()), |
|
|
|
lager_config:set(loglevel, {element(2, rumUtil:config_to_mask(debug)), []}), |
|
|
|
rumConfig:set(loglevel, {element(2, rumUtil:config_to_mask(debug)), []}), |
|
|
|
eRum:debug("this message should be ignored"), |
|
|
|
?assertEqual(0, count()), |
|
|
|
?assertEqual(1, count_ignored()), |
|
|
|
eRum:set_loglevel(?MODULE, debug), |
|
|
|
?assertEqual({?DEBUG bor ?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, lager_config:get(loglevel)), |
|
|
|
?assertEqual({?DEBUG bor ?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, rumConfig:get(loglevel)), |
|
|
|
eRum:debug("this message should be logged"), |
|
|
|
?assertEqual(1, count()), |
|
|
|
?assertEqual(1, count_ignored()), |
|
|
@ -432,11 +432,11 @@ lager_test_() -> |
|
|
|
}, |
|
|
|
{"tracing works", |
|
|
|
fun() -> |
|
|
|
lager_config:set(loglevel, {element(2, rumUtil:config_to_mask(error)), []}), |
|
|
|
rumConfig:set(loglevel, {element(2, rumUtil:config_to_mask(error)), []}), |
|
|
|
ok = eRum:info("hello world"), |
|
|
|
?assertEqual(0, count()), |
|
|
|
eRum:trace(?MODULE, [{module, ?MODULE}], debug), |
|
|
|
?assertMatch({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, _}, lager_config:get(loglevel)), |
|
|
|
?assertMatch({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, _}, rumConfig:get(loglevel)), |
|
|
|
%% elegible for tracing |
|
|
|
ok = eRum:info("hello world"), |
|
|
|
%% NOT elegible for tracing |
|
|
@ -448,8 +448,8 @@ lager_test_() -> |
|
|
|
{"tracing works with custom attributes", |
|
|
|
fun() -> |
|
|
|
eRum:set_loglevel(?MODULE, error), |
|
|
|
?assertEqual({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, lager_config:get(loglevel)), |
|
|
|
lager_config:set(loglevel, {element(2, rumUtil:config_to_mask(error)), []}), |
|
|
|
?assertEqual({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, rumConfig:get(loglevel)), |
|
|
|
rumConfig:set(loglevel, {element(2, rumUtil:config_to_mask(error)), []}), |
|
|
|
eRum:info([{requestid, 6}], "hello world"), |
|
|
|
?assertEqual(0, count()), |
|
|
|
eRum:trace(?MODULE, [{requestid, 6}, {foo, bar}], debug), |
|
|
@ -467,8 +467,8 @@ lager_test_() -> |
|
|
|
{"tracing works with custom attributes and event stream processing", |
|
|
|
fun() -> |
|
|
|
eRum:set_loglevel(?MODULE, error), |
|
|
|
?assertEqual({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, lager_config:get(loglevel)), |
|
|
|
lager_config:set(loglevel, {element(2, rumUtil:config_to_mask(error)), []}), |
|
|
|
?assertEqual({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, rumConfig:get(loglevel)), |
|
|
|
rumConfig:set(loglevel, {element(2, rumUtil:config_to_mask(error)), []}), |
|
|
|
eRum:info([{requestid, 6}], "hello world"), |
|
|
|
?assertEqual(0, count()), |
|
|
|
eRum:trace(?MODULE, [{requestid, '>', 5}, {requestid, '<', 7}, {foo, bar}], debug), |
|
|
@ -535,8 +535,8 @@ lager_test_() -> |
|
|
|
{"tracing custom attributes works with event stream processing statistics and reductions", |
|
|
|
fun() -> |
|
|
|
eRum:set_loglevel(?MODULE, error), |
|
|
|
?assertEqual({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, lager_config:get(loglevel)), |
|
|
|
lager_config:set(loglevel, {element(2, rumUtil:config_to_mask(error)), []}), |
|
|
|
?assertEqual({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, rumConfig:get(loglevel)), |
|
|
|
rumConfig:set(loglevel, {element(2, rumUtil:config_to_mask(error)), []}), |
|
|
|
eRum:info([{requestid, 6}], "hello world"), |
|
|
|
?assertEqual(0, count()), |
|
|
|
eRum:trace(?MODULE, [{beta, '*'}]), |
|
|
@ -590,7 +590,7 @@ lager_test_() -> |
|
|
|
{"tracing honors loglevel", |
|
|
|
fun() -> |
|
|
|
eRum:set_loglevel(?MODULE, error), |
|
|
|
?assertEqual({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, lager_config:get(loglevel)), |
|
|
|
?assertEqual({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, rumConfig:get(loglevel)), |
|
|
|
{ok, T} = eRum:trace(?MODULE, [{module, ?MODULE}], notice), |
|
|
|
ok = eRum:info("hello world"), |
|
|
|
?assertEqual(0, count()), |
|
|
@ -607,29 +607,29 @@ lager_test_() -> |
|
|
|
fun() -> |
|
|
|
Sink = ?RumDefSink, |
|
|
|
StartHandlers = gen_event:which_handlers(Sink), |
|
|
|
{_, T0} = lager_config:get({Sink, loglevel}), |
|
|
|
StartGlobal = lager_config:global_get(handlers), |
|
|
|
{_, T0} = rumConfig:get({Sink, loglevel}), |
|
|
|
StartGlobal = rumConfig:global_get(handlers), |
|
|
|
?assertEqual([], T0), |
|
|
|
{ok, TestTrace1} = eRum:trace_file("/tmp/test", [{a, b}]), |
|
|
|
MidHandlers = gen_event:which_handlers(Sink), |
|
|
|
{ok, TestTrace2} = eRum:trace_file("/tmp/test", [{c, d}]), |
|
|
|
MidHandlers = gen_event:which_handlers(Sink), |
|
|
|
?assertEqual(length(StartHandlers) + 1, length(MidHandlers)), |
|
|
|
MidGlobal = lager_config:global_get(handlers), |
|
|
|
MidGlobal = rumConfig:global_get(handlers), |
|
|
|
?assertEqual(length(StartGlobal) + 1, length(MidGlobal)), |
|
|
|
{_, T1} = lager_config:get({Sink, loglevel}), |
|
|
|
{_, T1} = rumConfig:get({Sink, loglevel}), |
|
|
|
?assertEqual(2, length(T1)), |
|
|
|
ok = eRum:stop_trace(TestTrace1), |
|
|
|
{_, T2} = lager_config:get({Sink, loglevel}), |
|
|
|
{_, T2} = rumConfig:get({Sink, loglevel}), |
|
|
|
?assertEqual(1, length(T2)), |
|
|
|
?assertEqual(length(StartHandlers) + 1, length( |
|
|
|
gen_event:which_handlers(Sink))), |
|
|
|
|
|
|
|
?assertEqual(length(StartGlobal) + 1, length(lager_config:global_get(handlers))), |
|
|
|
?assertEqual(length(StartGlobal) + 1, length(rumConfig:global_get(handlers))), |
|
|
|
ok = eRum:stop_trace(TestTrace2), |
|
|
|
EndHandlers = gen_event:which_handlers(Sink), |
|
|
|
EndGlobal = lager_config:global_get(handlers), |
|
|
|
{_, T3} = lager_config:get({Sink, loglevel}), |
|
|
|
EndGlobal = rumConfig:global_get(handlers), |
|
|
|
{_, T3} = rumConfig:get({Sink, loglevel}), |
|
|
|
?assertEqual([], T3), |
|
|
|
?assertEqual(StartHandlers, EndHandlers), |
|
|
|
?assertEqual(StartGlobal, EndGlobal), |
|
|
@ -687,9 +687,9 @@ lager_test_() -> |
|
|
|
}, |
|
|
|
{"installing a new handler adjusts the global loglevel if necessary", |
|
|
|
fun() -> |
|
|
|
?assertEqual({?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, lager_config:get(loglevel)), |
|
|
|
?assertEqual({?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, rumConfig:get(loglevel)), |
|
|
|
supervisor:start_child(lager_handler_watcher_sup, [lager_event, {?MODULE, foo}, debug]), |
|
|
|
?assertEqual({?DEBUG bor ?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, lager_config:get(loglevel)), |
|
|
|
?assertEqual({?DEBUG bor ?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, rumConfig:get(loglevel)), |
|
|
|
ok |
|
|
|
end |
|
|
|
}, |
|
|
@ -815,29 +815,29 @@ extra_sinks_test_() -> |
|
|
|
fun() -> |
|
|
|
Sink = ?TEST_SINK_EVENT, |
|
|
|
StartHandlers = gen_event:which_handlers(Sink), |
|
|
|
{_, T0} = lager_config:get({Sink, loglevel}), |
|
|
|
StartGlobal = lager_config:global_get(handlers), |
|
|
|
{_, T0} = rumConfig:get({Sink, loglevel}), |
|
|
|
StartGlobal = rumConfig:global_get(handlers), |
|
|
|
?assertEqual([], T0), |
|
|
|
{ok, TestTrace1} = eRum:trace_file("/tmp/test", [{sink, Sink}, {a, b}]), |
|
|
|
MidHandlers = gen_event:which_handlers(Sink), |
|
|
|
{ok, TestTrace2} = eRum:trace_file("/tmp/test", [{sink, Sink}, {c, d}]), |
|
|
|
MidHandlers = gen_event:which_handlers(Sink), |
|
|
|
?assertEqual(length(StartHandlers) + 1, length(MidHandlers)), |
|
|
|
MidGlobal = lager_config:global_get(handlers), |
|
|
|
MidGlobal = rumConfig:global_get(handlers), |
|
|
|
?assertEqual(length(StartGlobal) + 1, length(MidGlobal)), |
|
|
|
{_, T1} = lager_config:get({Sink, loglevel}), |
|
|
|
{_, T1} = rumConfig:get({Sink, loglevel}), |
|
|
|
?assertEqual(2, length(T1)), |
|
|
|
ok = eRum:stop_trace(TestTrace1), |
|
|
|
{_, T2} = lager_config:get({Sink, loglevel}), |
|
|
|
{_, T2} = rumConfig:get({Sink, loglevel}), |
|
|
|
?assertEqual(1, length(T2)), |
|
|
|
?assertEqual(length(StartHandlers) + 1, length( |
|
|
|
gen_event:which_handlers(Sink))), |
|
|
|
|
|
|
|
?assertEqual(length(StartGlobal) + 1, length(lager_config:global_get(handlers))), |
|
|
|
?assertEqual(length(StartGlobal) + 1, length(rumConfig:global_get(handlers))), |
|
|
|
ok = eRum:stop_trace(TestTrace2), |
|
|
|
EndHandlers = gen_event:which_handlers(Sink), |
|
|
|
EndGlobal = lager_config:global_get(handlers), |
|
|
|
{_, T3} = lager_config:get({Sink, loglevel}), |
|
|
|
EndGlobal = rumConfig:global_get(handlers), |
|
|
|
{_, T3} = rumConfig:get({Sink, loglevel}), |
|
|
|
?assertEqual([], T3), |
|
|
|
?assertEqual(StartHandlers, EndHandlers), |
|
|
|
?assertEqual(StartGlobal, EndGlobal), |
|
|
@ -850,12 +850,12 @@ extra_sinks_test_() -> |
|
|
|
?TEST_SINK_NAME:debug("this message will be ignored"), |
|
|
|
?assertEqual(0, count(?TEST_SINK_EVENT)), |
|
|
|
?assertEqual(0, count_ignored(?TEST_SINK_EVENT)), |
|
|
|
lager_config:set({?TEST_SINK_EVENT, loglevel}, {element(2, rumUtil:config_to_mask(debug)), []}), |
|
|
|
rumConfig:set({?TEST_SINK_EVENT, loglevel}, {element(2, rumUtil:config_to_mask(debug)), []}), |
|
|
|
?TEST_SINK_NAME:debug("this message should be ignored"), |
|
|
|
?assertEqual(0, count(?TEST_SINK_EVENT)), |
|
|
|
?assertEqual(1, count_ignored(?TEST_SINK_EVENT)), |
|
|
|
eRum:set_loglevel(?TEST_SINK_EVENT, ?MODULE, undefined, debug), |
|
|
|
?assertEqual({?DEBUG bor ?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, lager_config:get({?TEST_SINK_EVENT, loglevel})), |
|
|
|
?assertEqual({?DEBUG bor ?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, rumConfig:get({?TEST_SINK_EVENT, loglevel})), |
|
|
|
?TEST_SINK_NAME:debug("this message should be logged"), |
|
|
|
?assertEqual(1, count(?TEST_SINK_EVENT)), |
|
|
|
?assertEqual(1, count_ignored(?TEST_SINK_EVENT)), |
|
|
@ -1455,7 +1455,7 @@ error_logger_redirect_test_() -> |
|
|
|
{"supervisor progress report", |
|
|
|
fun(Sink) -> |
|
|
|
eRum:set_loglevel(Sink, ?MODULE, undefined, debug), |
|
|
|
?assertEqual({?DEBUG bor ?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, lager_config:get({Sink, loglevel})), |
|
|
|
?assertEqual({?DEBUG bor ?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, rumConfig:get({Sink, loglevel})), |
|
|
|
sync_error_logger:info_report(progress, [{supervisor, {local, foo}}, {started, [{mfargs, {foo, bar, 1}}, {pid, baz}]}]), |
|
|
|
_ = gen_event:which_handlers(error_logger), |
|
|
|
{Level, _, Msg, Metadata} = pop(Sink), |
|
|
@ -1467,7 +1467,7 @@ error_logger_redirect_test_() -> |
|
|
|
{"supervisor progress report with pid", |
|
|
|
fun(Sink) -> |
|
|
|
eRum:set_loglevel(Sink, ?MODULE, undefined, debug), |
|
|
|
?assertEqual({?DEBUG bor ?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, lager_config:get({Sink, loglevel})), |
|
|
|
?assertEqual({?DEBUG bor ?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, rumConfig:get({Sink, loglevel})), |
|
|
|
sync_error_logger:info_report(progress, [{supervisor, somepid}, {started, [{mfargs, {foo, bar, 1}}, {pid, baz}]}]), |
|
|
|
_ = gen_event:which_handlers(error_logger), |
|
|
|
{Level, _, Msg, Metadata} = pop(Sink), |
|
|
@ -1694,20 +1694,20 @@ error_logger_redirect_test_() -> |
|
|
|
{"messages should not be generated if they don't satisfy the threshold", |
|
|
|
fun(Sink) -> |
|
|
|
eRum:set_loglevel(Sink, ?MODULE, undefined, error), |
|
|
|
?assertEqual({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, lager_config:get({Sink, loglevel})), |
|
|
|
?assertEqual({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, rumConfig:get({Sink, loglevel})), |
|
|
|
sync_error_logger:info_report([hello, world]), |
|
|
|
_ = gen_event:which_handlers(error_logger), |
|
|
|
?assertEqual(0, count(Sink)), |
|
|
|
?assertEqual(0, count_ignored(Sink)), |
|
|
|
eRum:set_loglevel(Sink, ?MODULE, undefined, info), |
|
|
|
?assertEqual({?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, lager_config:get({Sink, loglevel})), |
|
|
|
?assertEqual({?INFO bor ?NOTICE bor ?WARNING bor ?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, rumConfig:get({Sink, loglevel})), |
|
|
|
sync_error_logger:info_report([hello, world]), |
|
|
|
_ = gen_event:which_handlers(error_logger), |
|
|
|
?assertEqual(1, count(Sink)), |
|
|
|
?assertEqual(0, count_ignored(Sink)), |
|
|
|
eRum:set_loglevel(Sink, ?MODULE, undefined, error), |
|
|
|
?assertEqual({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, lager_config:get({Sink, loglevel})), |
|
|
|
lager_config:set({Sink, loglevel}, {element(2, rumUtil:config_to_mask(debug)), []}), |
|
|
|
?assertEqual({?ERROR bor ?CRITICAL bor ?ALERT bor ?EMERGENCY, []}, rumConfig:get({Sink, loglevel})), |
|
|
|
rumConfig:set({Sink, loglevel}, {element(2, rumUtil:config_to_mask(debug)), []}), |
|
|
|
sync_error_logger:info_report([hello, world]), |
|
|
|
_ = gen_event:which_handlers(error_logger), |
|
|
|
?assertEqual(1, count(Sink)), |
|
|
@ -1779,7 +1779,7 @@ async_threshold_test_() -> |
|
|
|
Sleep = get_long_sleep_value(), |
|
|
|
|
|
|
|
%% we start out async |
|
|
|
?assertEqual(true, lager_config:get(async)), |
|
|
|
?assertEqual(true, rumConfig:get(async)), |
|
|
|
?assertEqual([{sync_toggled, 0}], |
|
|
|
ets:lookup(async_threshold_test, sync_toggled)), |
|
|
|
|
|
|
@ -1817,7 +1817,7 @@ async_threshold_test_() -> |
|
|
|
timer:sleep(Sleep), |
|
|
|
|
|
|
|
%% async is true again now that the mailbox has drained |
|
|
|
?assertEqual(true, lager_config:get(async)), |
|
|
|
?assertEqual(true, rumConfig:get(async)), |
|
|
|
ok |
|
|
|
end}} |
|
|
|
]}. |
|
|
|