diff options
author | Hans Nilsson <[email protected]> | 2016-10-14 10:15:13 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2016-10-14 10:15:13 +0200 |
commit | 9eee0bb5cc74d037ce89521b9a1fec4a289e4880 (patch) | |
tree | 7f41e1612c113f8beb50d3e8b2e26155dd00a3d7 /lib/ssh/test/ssh_eqc_event_handler.erl | |
parent | 3d925002ceed8f0a739e17e65643a20f6c3f1142 (diff) | |
parent | df8c6690a86d087d8de324276b2266bc5918c779 (diff) | |
download | otp-9eee0bb5cc74d037ce89521b9a1fec4a289e4880.tar.gz otp-9eee0bb5cc74d037ce89521b9a1fec4a289e4880.tar.bz2 otp-9eee0bb5cc74d037ce89521b9a1fec4a289e4880.zip |
Merge branch 'maint'
Conflicts:
OTP_VERSION
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}. |