diff options
author | Hans Nilsson <[email protected]> | 2016-10-14 10:14:08 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2016-10-14 10:14:08 +0200 |
commit | df8c6690a86d087d8de324276b2266bc5918c779 (patch) | |
tree | 9f4212bfb907d69ad0aae9969ee02d12562ea4fb /lib/ssh/test/ssh_eqc_event_handler.erl | |
parent | 28d84f10b99906d44d4bb842f17ecc4472cb3d92 (diff) | |
parent | c1c2149818396bdefe9eff995184f8864f18fca3 (diff) | |
download | otp-df8c6690a86d087d8de324276b2266bc5918c779.tar.gz otp-df8c6690a86d087d8de324276b2266bc5918c779.tar.bz2 otp-df8c6690a86d087d8de324276b2266bc5918c779.zip |
Merge branch 'maint-19' into maint
Diffstat (limited to 'lib/ssh/test/ssh_eqc_event_handler.erl')
-rw-r--r-- | lib/ssh/test/ssh_eqc_event_handler.erl | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/ssh/test/ssh_eqc_event_handler.erl b/lib/ssh/test/ssh_eqc_event_handler.erl new file mode 100644 index 0000000000..233965012a --- /dev/null +++ b/lib/ssh/test/ssh_eqc_event_handler.erl @@ -0,0 +1,43 @@ +-module(ssh_eqc_event_handler). + +-compile(export_all). + +-behaviour(gen_event). + +add_report_handler() -> + error_logger:add_report_handler(?MODULE, [self(),Ref=make_ref()]), + receive + {event_handler_started,HandlerPid,Ref} -> + {ok,HandlerPid} + end. + +get_reports(Pid) -> + Pid ! {get_reports,self(),Ref=make_ref()}, + receive + {reports,Reports,Ref} -> + {ok,Reports} + end. + +%%%================================================================ + +-record(state, { + reports = [] + }). + +%% error_logger:add_report_handler(ssh_eqc_event_handler, [self()]). + +init([CallerPid,Ref]) -> + CallerPid ! {event_handler_started,self(),Ref}, + {ok, #state{}}. + +handle_event(Event, State) -> + {ok, State#state{reports = [Event|State#state.reports]}}. + +handle_info({get_reports,From,Ref}, State) -> + From ! {reports, lists:reverse(State#state.reports), Ref}, + {ok, State#state{reports=[]}}. + +handle_call(_Request, State) -> {ok,reply,State}. +terminate(_Arg, _State) -> stop. + +code_change(_OldVsn, State, _Extra) -> {ok, State}. |