remove lager

This commit is contained in:
anlicheng 2026-01-08 15:23:35 +08:00
parent 5111914a9b
commit c590588b16

View File

@ -782,16 +782,16 @@ connected(cast, ?PUBREC_PACKET(PacketId), State = #state{inflight = Inflight}) -
Inflight1 = maps:put(PacketId, {pubrel, PacketId, os:timestamp()}, Inflight), Inflight1 = maps:put(PacketId, {pubrel, PacketId, os:timestamp()}, Inflight),
State#state{inflight = Inflight1}; State#state{inflight = Inflight1};
{ok, {pubrel, _Ref, _Ts}} -> {ok, {pubrel, _Ref, _Ts}} ->
lager:notice("[emqtt] Duplicated PUBREC Packet: ~p, client_id: ~p", [PacketId, State#state.clientid]), logger:notice("[emqtt] Duplicated PUBREC Packet: ~p, client_id: ~p", [PacketId, State#state.clientid]),
State; State;
error -> error ->
lager:warning("[emqtt] Unexpected PUBREC Packet: ~p, client_id: ~p", [PacketId, State#state.clientid]), logger:warning("[emqtt] Unexpected PUBREC Packet: ~p, client_id: ~p", [PacketId, State#state.clientid]),
State State
end, end,
send_puback(?PUBREL_PACKET(PacketId), NState); send_puback(?PUBREL_PACKET(PacketId), NState);
connected(cast, ?PUBREC_PACKET(PacketId, ReasonCode), State) -> connected(cast, ?PUBREC_PACKET(PacketId, ReasonCode), State) ->
lager:notice("[emqtt] Duplicated PUBREC Packet: ~p, reason_code: ~p, client_id: ~p", [PacketId, ReasonCode, State#state.clientid]), logger:notice("[emqtt] Duplicated PUBREC Packet: ~p, reason_code: ~p, client_id: ~p", [PacketId, ReasonCode, State#state.clientid]),
keep_state_and_data; keep_state_and_data;
%%TODO::... if auto_ack is false, should we take PacketId from the map? %%TODO::... if auto_ack is false, should we take PacketId from the map?
@ -805,7 +805,7 @@ connected(cast, ?PUBREL_PACKET(PacketId),
false -> {keep_state, NewState} false -> {keep_state, NewState}
end; end;
error -> error ->
lager:warning("[emqtt] Unexpected PUBREL: ~p, client_id: ~p", [PacketId, State#state.clientid]), logger:warning("[emqtt] Unexpected PUBREL: ~p, client_id: ~p", [PacketId, State#state.clientid]),
keep_state_and_data keep_state_and_data
end; end;
@ -904,34 +904,34 @@ handle_event({call, From}, stop, _StateName, _State) ->
{stop_and_reply, normal, [{reply, From, ok}]}; {stop_and_reply, normal, [{reply, From, ok}]};
handle_event(info, {TcpOrSsL, _Sock, Data}, _StateName, State) when TcpOrSsL =:= tcp; TcpOrSsL =:= ssl -> handle_event(info, {TcpOrSsL, _Sock, Data}, _StateName, State) when TcpOrSsL =:= tcp; TcpOrSsL =:= ssl ->
%lager:debug("[emqtt] RECV Data: ~p, client_id: ~p", [Data, State#state.clientid]), %logger:debug("[emqtt] RECV Data: ~p, client_id: ~p", [Data, State#state.clientid]),
process_incoming(Data, [], run_sock(State)); process_incoming(Data, [], run_sock(State));
handle_event(info, {Error, _Sock, Reason}, _StateName, State) when Error =:= tcp_error; Error =:= ssl_error -> handle_event(info, {Error, _Sock, Reason}, _StateName, State) when Error =:= tcp_error; Error =:= ssl_error ->
lager:error("[emqtt] The connection error occured ~p, reason:~p, client_id: ~p", [Error, Reason, State#state.clientid]), logger:error("[emqtt] The connection error occured ~p, reason:~p, client_id: ~p", [Error, Reason, State#state.clientid]),
{stop, {shutdown, Reason}, State}; {stop, {shutdown, Reason}, State};
handle_event(info, {Closed, _Sock}, _StateName, State) when Closed =:= tcp_closed; Closed =:= ssl_closed -> handle_event(info, {Closed, _Sock}, _StateName, State) when Closed =:= tcp_closed; Closed =:= ssl_closed ->
lager:debug("[emqtt] sokcet closed: ~p, client_id: ~p", [Closed, State#state.clientid]), logger:debug("[emqtt] sokcet closed: ~p, client_id: ~p", [Closed, State#state.clientid]),
{stop, {shutdown, Closed}, State}; {stop, {shutdown, Closed}, State};
handle_event(info, {'EXIT', Owner, Reason}, _, State = #state{owner = Owner}) -> handle_event(info, {'EXIT', Owner, Reason}, _, State = #state{owner = Owner}) ->
lager:warning("[emqtt] Got EXIT from owner, Reason: ~p, client_id: ~p", [Reason, State#state.clientid]), logger:warning("[emqtt] Got EXIT from owner, Reason: ~p, client_id: ~p", [Reason, State#state.clientid]),
{stop, {shutdown, Reason}, State}; {stop, {shutdown, Reason}, State};
handle_event(info, {inet_reply, _Sock, ok}, _, _State) -> handle_event(info, {inet_reply, _Sock, ok}, _, _State) ->
keep_state_and_data; keep_state_and_data;
handle_event(info, {inet_reply, _Sock, {error, Reason}}, _, State) -> handle_event(info, {inet_reply, _Sock, {error, Reason}}, _, State) ->
lager:error("[emqtt] Got tcp error: ~p, client_id: ~p", [Reason, State#state.clientid]), logger:error("[emqtt] Got tcp error: ~p, client_id: ~p", [Reason, State#state.clientid]),
{stop, {shutdown, Reason}, State}; {stop, {shutdown, Reason}, State};
handle_event(info, EventContent = {'EXIT', Pid, Reason}, StateName, State) -> handle_event(info, EventContent = {'EXIT', Pid, Reason}, StateName, State) ->
lager:warning("[emqtt] State: ~s, Unexpected Event: (info, ~p), from pid: ~p, client_id: ~p", [StateName, EventContent, Pid, State#state.clientid]), logger:warning("[emqtt] State: ~s, Unexpected Event: (info, ~p), from pid: ~p, client_id: ~p", [StateName, EventContent, Pid, State#state.clientid]),
{stop, {shutdown, Reason}, State}; {stop, {shutdown, Reason}, State};
handle_event(EventType, EventContent, StateName, State) -> handle_event(EventType, EventContent, StateName, State) ->
lager:error("[emqtt] State: ~s, Unexpected Event: (~p, ~p), client_id: ~p", [StateName, EventType, EventContent, State#state.clientid]), logger:error("[emqtt] State: ~s, Unexpected Event: (~p, ~p), client_id: ~p", [StateName, EventType, EventContent, State#state.clientid]),
keep_state_and_data. keep_state_and_data.
%% Mandatory callback functions %% Mandatory callback functions
@ -978,7 +978,7 @@ delete_inflight(?PUBACK_PACKET(PacketId, ReasonCode, Properties),
properties => Properties}), properties => Properties}),
State#state{inflight = maps:remove(PacketId, Inflight)}; State#state{inflight = maps:remove(PacketId, Inflight)};
error -> error ->
lager:warning("[emqtt] Unexpected PUBACK: ~p, client_id: ~p", [PacketId, State#state.clientid]), logger:warning("[emqtt] Unexpected PUBACK: ~p, client_id: ~p", [PacketId, State#state.clientid]),
State State
end; end;
delete_inflight(?PUBCOMP_PACKET(PacketId, ReasonCode, Properties), delete_inflight(?PUBCOMP_PACKET(PacketId, ReasonCode, Properties),
@ -990,7 +990,7 @@ delete_inflight(?PUBCOMP_PACKET(PacketId, ReasonCode, Properties),
properties => Properties}), properties => Properties}),
State#state{inflight = maps:remove(PacketId, Inflight)}; State#state{inflight = maps:remove(PacketId, Inflight)};
error -> error ->
lager:warning("[emqtt] Unexpected PUBCOMP Packet: ~p, client_id: ~p", [PacketId, State#state.clientid]), logger:warning("[emqtt] Unexpected PUBCOMP Packet: ~p, client_id: ~p", [PacketId, State#state.clientid]),
State State
end. end.