fix logger
This commit is contained in:
parent
77d3b765d7
commit
d66ab5a5ca
@ -171,7 +171,7 @@ handle_info({connect_reply, Reply}, State = #state{status = ?STATE_CONNECTING, t
|
||||
efka_transport:auth_request(TransportPid, 5000),
|
||||
{noreply, State#state{status = ?STATE_AUTH}};
|
||||
{error, Reason} ->
|
||||
efka_logger:debug("[efka_agent] connect failed, error: ~p, pid: ~p", [Reason, TransportPid]),
|
||||
lager:debug("[efka_agent] connect failed, error: ~p, pid: ~p", [Reason, TransportPid]),
|
||||
efka_transport:stop(TransportPid),
|
||||
{noreply, State#state{status = ?STATE_DENIED}}
|
||||
end;
|
||||
@ -200,7 +200,7 @@ handle_info({auth_reply, Reply}, State = #state{status = ?STATE_AUTH, transport_
|
||||
{noreply, State#state{status = ?STATE_RESTRICTED}};
|
||||
2 ->
|
||||
% 其他类型的错误,需要间隔时间重试
|
||||
efka_logger:debug("[efka_agent] auth failed, message: ~p", [Message]),
|
||||
lager:debug("[efka_agent] auth failed, message: ~p", [Message]),
|
||||
efka_transport:stop(TransportPid),
|
||||
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}};
|
||||
_ ->
|
||||
@ -300,7 +300,7 @@ handle_info({server_command, ?COMMAND_AUTH, <<Auth:8>>}, State = #state{transpor
|
||||
|
||||
%% 收到需要回复的指令
|
||||
handle_info({server_pub, Topic, Content}, State = #state{status = ?STATE_ACTIVATED}) ->
|
||||
efka_logger:debug("[efka_agent] get pub topic: ~p, content: ~p", [Topic, Content]),
|
||||
lager:debug("[efka_agent] get pub topic: ~p, content: ~p", [Topic, Content]),
|
||||
%% 消息发送到订阅系统
|
||||
efka_subscription:publish(Topic, Content),
|
||||
|
||||
@ -337,7 +337,7 @@ handle_info({timeout, _, {request_timeout, Ref}}, State = #state{inflight = Infl
|
||||
|
||||
%% transport进程退出
|
||||
handle_info({'EXIT', TransportPid, Reason}, State = #state{transport_pid = TransportPid}) ->
|
||||
efka_logger:debug("[efka_agent] transport pid: ~p, exit with reason: ~p", [TransportPid, Reason]),
|
||||
lager:debug("[efka_agent] transport pid: ~p, exit with reason: ~p", [TransportPid, Reason]),
|
||||
erlang:start_timer(5000, self(), create_transport),
|
||||
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}};
|
||||
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @author anlicheng
|
||||
%%% @copyright (C) 2025, <COMPANY>
|
||||
%%% @doc
|
||||
%%%
|
||||
%%% @end
|
||||
%%% Created : 29. 4月 2025 22:39
|
||||
%%%-------------------------------------------------------------------
|
||||
-module(efka_logger).
|
||||
-author("anlicheng").
|
||||
|
||||
%% API
|
||||
-export([debug/2, notice/2]).
|
||||
|
||||
debug(Format, Args) ->
|
||||
io:format(Format ++ "~n", Args).
|
||||
|
||||
notice(Format, Args) ->
|
||||
io:format(Format ++ "~n", Args).
|
||||
@ -108,7 +108,7 @@ handle_cast({publish, Topic, Content}, State = #state{subscribers = Subscribers}
|
||||
SubscriberPid ! {topic_broadcast, Topic, Content}
|
||||
end, MatchedSubscribers),
|
||||
|
||||
efka_logger:debug("[efka_subscription] topic: ~p, content: ~p, match subscribers: ~p", [Topic, Content, MatchedSubscribers]),
|
||||
lager:debug("[efka_subscription] topic: ~p, content: ~p, match subscribers: ~p", [Topic, Content, MatchedSubscribers]),
|
||||
{noreply, State}.
|
||||
|
||||
%% @private
|
||||
@ -118,12 +118,12 @@ handle_cast({publish, Topic, Content}, State = #state{subscribers = Subscribers}
|
||||
{noreply, NewState :: #state{}, timeout() | hibernate} |
|
||||
{stop, Reason :: term(), NewState :: #state{}}).
|
||||
handle_info({'DOWN', _Ref, process, SubscriberPid, Reason}, State = #state{subscribers = Subscribers}) ->
|
||||
efka_logger:debug("[efka_subscription] subscriber: ~p, down with reason: ~p", [SubscriberPid, Reason]),
|
||||
lager:debug("[efka_subscription] subscriber: ~p, down with reason: ~p", [SubscriberPid, Reason]),
|
||||
NSubscribers = lists:filter(fun(#subscriber{subscriber_pid = Pid0}) -> SubscriberPid /= Pid0 end, Subscribers),
|
||||
{noreply, State#state{subscribers = NSubscribers}};
|
||||
|
||||
handle_info(Info, State = #state{}) ->
|
||||
efka_logger:debug("[efka_subscription] get unknown info: ~p", [Info]),
|
||||
lager:debug("[efka_subscription] get unknown info: ~p", [Info]),
|
||||
{noreply, State}.
|
||||
|
||||
%% @private
|
||||
|
||||
@ -182,7 +182,7 @@ handle_info(Info, State = #state{}) ->
|
||||
-spec(terminate(Reason :: (normal | shutdown | {shutdown, term()} | term()),
|
||||
State :: #state{}) -> term()).
|
||||
terminate(Reason, #state{}) ->
|
||||
efka_logger:notice("[efka_transport] terminate with reason: ~p", [Reason]),
|
||||
lager:notice("[efka_transport] terminate with reason: ~p", [Reason]),
|
||||
ok.
|
||||
|
||||
%% @private
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user