From d774f3668e620b239df91af01cbda043b580405b Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Fri, 28 Jun 2019 12:54:24 +0200 Subject: prepend debug printouts with own pid --- p11p-daemon/src/p11p_remote.erl | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'p11p-daemon/src/p11p_remote.erl') diff --git a/p11p-daemon/src/p11p_remote.erl b/p11p-daemon/src/p11p_remote.erl index e89aa42..784f938 100644 --- a/p11p-daemon/src/p11p_remote.erl +++ b/p11p-daemon/src/p11p_remote.erl @@ -10,7 +10,6 @@ %% from p11p-kit -module(p11p_remote). - -behaviour(gen_server). %% API. @@ -29,6 +28,7 @@ token :: string() }). +%% FIXME: move to config -define(P11KITREMOTE_PATH, "/home/linus/usr/libexec/p11-kit/p11-kit-remote"). %% API. @@ -37,7 +37,7 @@ start_link(ServName, TokName, ModPath) -> lager:info("~p: p11p_remote starting for ~s", [ServName, ModPath]), gen_server:start_link({local, ServName}, ?MODULE, [TokName, ModPath], []). --spec send(pid(), pid(), iodata()) -> ok. +-spec send(pid(), pid(), binary()) -> ok. send(From, Remote, Data) -> gen_server:cast(Remote, {send, From, Data}). @@ -45,24 +45,21 @@ send(From, Remote, Data) -> init([TokName, ModPath]) -> Port = open_port({spawn_executable, ?P11KITREMOTE_PATH}, [stream, exit_status, {args, [ModPath, "-v"]}]), - lager:debug("~s: New port: ~p", [?P11KITREMOTE_PATH, Port]), + lager:debug("~p: ~s: New port: ~p", [self(), ?P11KITREMOTE_PATH, Port]), {ok, #state{port = Port, token = TokName}}. handle_call(Request, _From, State) -> - lager:debug("Unhandled call: ~p~n", [Request]), + lager:debug("~p: Unhandled call: ~p~n", [self(), Request]), {reply, unhandled, State}. handle_cast({send, From, Data}, #state{port = Port} = State) -> - lager:debug("~p: sending ~B octets to remote ~p", - [self(), length(binary_to_list(Data)), Port]), + lager:debug("~p: sending request to remote ~p", [self(), Port]), port_command(Port, Data), - %% TODO: move timing to server, measuring time for a p11 response - %% rather than this Timer = erlang:start_timer(3000, self(), Port), NewState = State#state{replyto = From, timer = Timer}, {noreply, NewState}; handle_cast(Request, State) -> - lager:debug("Unhandled cast: ~p~n", [Request]), + lager:debug("~p: Unhandled cast: ~p~n", [self(), Request]), {noreply, State}. handle_info({Port, {data, Data}}, #state{replyto = Pid, timer = Timer} = State) -> @@ -87,7 +84,7 @@ handle_info({timeout, Timer, Port}, #state{token = TokName} = State) -> end, {noreply, NewState}; handle_info(Info, State) -> - lager:debug("Unhandled info: ~p~n", [Info]), + lager:debug("~p: Unhandled info: ~p~n", [self(), Info]), {noreply, State}. terminate(_Reason, _State) -> -- cgit v1.1