Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add app env 'sync_dispatch_log' to switch the sync and async modes of…

… lager:dispatch_log/8
  • Loading branch information...
commit 7ad002bf256832deeef52cf6c424089ee93ff4d1 1 parent 4542f78
@aleksandr-vin authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/lager.erl
View
14 src/lager.erl
@@ -74,8 +74,18 @@ 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:notify(Pid, {log, lager_msg:new(Msg, Timestamp,
- Severity, Metadata, Destinations)});
+ SyncMode =
+ case application:get_env(lager, sync_dispatch_log) of
+ {ok, true} -> true;
+ _ -> false
+ end,
+ if SyncMode ->
+ gen_event:sync_notify(Pid, {log, lager_msg:new(Msg, Timestamp,
+ Severity, Metadata, Destinations)});
+ true ->
+ gen_event:notify(Pid, {log, lager_msg:new(Msg, Timestamp,
+ Severity, Metadata, Destinations)})
+ end;
_ ->
ok
end
Please sign in to comment.
Something went wrong with that request. Please try again.