Skip to content
Browse files

Tag lager_msg messages with a {log, ...} tuple

Helps with pattern matching.
  • Loading branch information...
1 parent 180e09f commit e04830b3828c51191aef334a62756e43830b1e71 @Vagabond Vagabond committed Sep 26, 2012
Showing with 7 additions and 7 deletions.
  1. +2 −2 include/lager.hrl
  2. +2 −2 src/lager.erl
  3. +1 −1 src/lager_console_backend.erl
  4. +1 −1 src/lager_file_backend.erl
  5. +1 −1 test/lager_test_backend.erl
View
4 include/lager.hrl
@@ -58,11 +58,11 @@
lager_util:level_to_num(Level) =< element(1, lager_mochiglobal:get(loglevel, {?LOG_NONE, []}))).
-define(NOTIFY(Level, Pid, Format, Args),
- gen_event:notify(lager_event,lager_msg:new(io_lib:format(Format, Args),
+ gen_event:notify(lager_event, {log, lager_msg:new(io_lib:format(Format, Args),
lager_util:format_time(),
Level,
[{pid,Pid},{line,?LINE},{file,?FILE},{module,?MODULE}],
- [])
+ [])}
)).
%% FOR INTERNAL USE ONLY
View
4 src/lager.erl
@@ -74,8 +74,8 @@ dispatch_log(Severity, Metadata, Format, Args, Size) when is_atom(Severity)->
A when is_list(A) ->safe_format_chop(Format,Args,Size);
_ -> Format
end,
- gen_event:sync_notify(Pid, lager_msg:new(Msg, Timestamp,
- Severity, Metadata, Destinations));
+ gen_event:sync_notify(Pid, {log, lager_msg:new(Msg, Timestamp,
+ Severity, Metadata, Destinations)});
_ ->
ok
end
View
2 src/lager_console_backend.erl
@@ -67,7 +67,7 @@ handle_call(_Request, State) ->
{ok, ok, State}.
%% @private
-handle_event(Message,
+handle_event({log, Message},
#state{level=L,formatter=Formatter,format_config=FormatConfig} = State) ->
case lager_util:is_loggable(Message, L, ?MODULE) of
true ->
View
2 src/lager_file_backend.erl
@@ -91,7 +91,7 @@ handle_call(_Request, State) ->
{ok, ok, State}.
%% @private
-handle_event(Message,
+handle_event({log, Message},
#state{name=Name, level=L,formatter=Formatter,formatter_config=FormatConfig} = State) ->
case lager_util:is_loggable(Message,L,{lager_file_backend, Name}) of
true ->
View
2 test/lager_test_backend.erl
@@ -54,7 +54,7 @@ handle_call({set_loglevel, Level}, State) ->
handle_call(_Request, State) ->
{ok, ok, State}.
-handle_event(Msg,
+handle_event({log, Msg},
#state{level=LogLevel,buffer=Buffer,ignored=Ignored} = State) ->
case lager_util:is_loggable(Msg, LogLevel, ?MODULE) of
true -> {ok, State#state{buffer=Buffer ++

0 comments on commit e04830b

Please sign in to comment.
Something went wrong with that request. Please try again.