Просмотр исходного кода

Add support for logger per module filtering (#2873)

Add mfa to the meta data to suppor the Erlang Logger's per module / per app filtering
Michael Schmidt 6 лет назад
Родитель
Сommit
3038bd4570
2 измененных файлов с 2 добавлено и 2 удалено
  1. 1 1
      include/logger.hrl
  2. 1 1
      src/emqx_tracer.erl

+ 1 - 1
include/logger.hrl

@@ -43,6 +43,6 @@
 
 -define(LOG(Level, Format, Args),
         begin
-          (logger:log(Level,#{},#{report_cb => fun(_) -> {'$logger_header'()++(Format), (Args)} end}))
+          (logger:log(Level,#{},#{report_cb => fun(_) -> {'$logger_header'()++(Format), (Args)} end, mfa => {?MODULE, ?FUNCTION_NAME, ?FUNCTION_ARITY}}))
         end).
 

+ 1 - 1
src/emqx_tracer.erl

@@ -65,7 +65,7 @@ trace(publish, #message{topic = <<"$SYS/", _/binary>>}) ->
     ignore;
 trace(publish, #message{from = From, topic = Topic, payload = Payload})
         when is_binary(From); is_atom(From) ->
-    emqx_logger:info(#{topic => Topic}, "PUBLISH to ~s: ~p", [Topic, Payload]).
+    emqx_logger:info(#{topic => Topic, mfa => {?MODULE, ?FUNCTION_NAME, ?FUNCTION_ARITY} }, "PUBLISH to ~s: ~p", [Topic, Payload]).
 
 %% @doc Start to trace client_id or topic.
 -spec(start_trace(trace_who(), logger:level(), string()) -> ok | {error, term()}).