From 27a184e8da65dd5294776f82e5acba485b56b757 Mon Sep 17 00:00:00 2001 From: zhouzb Date: Sun, 29 Sep 2019 16:38:21 +0800 Subject: [PATCH 1/3] Rename 'client_id' field to 'clientid' --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 56d36a66..de6a542b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Here is the simple usage of `emqtt` library. ``` erlang ClientId = <<"test">>. -{ok, ConnPid} = emqtt:start_link([{client_id, ClientId}]). +{ok, ConnPid} = emqtt:start_link([{clientid, ClientId}]). {ok, _Props} = emqtt:connect(ConnPid). Topic = <<"guide/#">>. QoS = 1. @@ -49,7 +49,7 @@ Receive(). ok = emqtt:disconnect(ConnPid). ``` -Not only the `client_id` can be passed as parameter, but also a lot of other options +Not only the `clientid` can be passed as parameter, but also a lot of other options can be passed as parameters. Here is the options which could be passed into emqtt:start_link/1. @@ -67,7 +67,7 @@ Here is the options which could be passed into emqtt:start_link/1. | {ws_path, string()} | {connect_timeout, pos_integer()} | {bridge_mode, boolean()} - | {client_id, iodata()} + | {clientid, iodata()} | {clean_start, boolean()} | {username, iodata()} | {password, iodata()} From 783c943f7aa1295b99f4a0c20436978eb6b70053 Mon Sep 17 00:00:00 2001 From: Ferenc Holzhauser Date: Mon, 16 Dec 2019 08:38:11 +0100 Subject: [PATCH 2/3] Fix shutdown reason in case of connect error (#96) --- src/emqtt.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emqtt.erl b/src/emqtt.erl index 746eae56..5d085dc9 100644 --- a/src/emqtt.erl +++ b/src/emqtt.erl @@ -626,7 +626,7 @@ initialized({call, From}, {connect, ConnMod}, State = #state{sock_opts = SockOpt {stop_and_reply, Reason, [{reply, From, Error}]} end; Error = {error, Reason} -> - {stop_and_reply, Reason, [{reply, From, Error}]} + {stop_and_reply, {shutdown, Reason}, [{reply, From, Error}]} end; initialized(EventType, EventContent, State) -> From cb97ec1806fb0708948c616a4b8bac2aebc44932 Mon Sep 17 00:00:00 2001 From: Ferenc Holzhauser Date: Sun, 12 Jan 2020 00:21:28 +0100 Subject: [PATCH 3/3] Add logger mfa metadata to enable module level --- src/emqtt.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emqtt.erl b/src/emqtt.erl index 5d085dc9..fe7a08d1 100644 --- a/src/emqtt.erl +++ b/src/emqtt.erl @@ -223,7 +223,7 @@ -define(LOG(Level, Format, Args, State), begin - (logger:log(Level, #{}, #{report_cb => fun(_) -> {"emqtt(~s): "++(Format), ([State#state.clientid|Args])} end})) + (logger:log(Level, #{}, #{mfa => {?MODULE, ?FUNCTION_NAME, ?FUNCTION_ARITY}, report_cb => fun(_) -> {"emqtt(~s): "++(Format), ([State#state.clientid|Args])} end})) end). %%--------------------------------------------------------------------