Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use sync_notify, its faster

  • Loading branch information...
commit d19d927da6b385cc6ea1af23a4f8f5d21dcb586d 1 parent 0bb86d5
@Vagabond Vagabond authored
Showing with 5 additions and 4 deletions.
  1. +1 −0  rebar.config
  2. +4 −4 src/lager.erl
View
1  rebar.config
@@ -1,6 +1,7 @@
{erl_opts, [debug_info, fail_on_warning]}.
+{cover_enabled, true}.
{deps, [
{riak_err, "1.0.*", {git, "git://github.com/basho/riak_err.git", {branch, "master"}}}
View
8 src/lager.erl
@@ -37,7 +37,7 @@ start_link() ->
undefined ->
[{lager_console_backend, [info]},
{lager_file_backend, [{"error.log", error}, {"console.log", info}]}];
- Val ->
+ {ok, Val} ->
Val
end,
gen_server:start_link({local, ?MODULE}, ?MODULE, [Handlers], []).
@@ -47,7 +47,7 @@ start() ->
undefined ->
[{lager_console_backend, [info]},
{lager_file_backend, [{"error.log", error}, {"console.log", info}]}];
- Val ->
+ {ok, Val} ->
Val
end,
gen_server:start({local, ?MODULE}, ?MODULE, [Handlers], []).
@@ -64,13 +64,13 @@ log(Level, Module, Function, Line, Pid, {{Y, M, D}, {H, Mi, S}}, Message) ->
Time = io_lib:format("~b-~b-~b ~b:~b:~b", [Y, M, D, H, Mi, S]),
Msg = io_lib:format("[~p] ~p@~p:~p:~p ~s", [Level, Pid, Module,
Function, Line, Message]),
- gen_event:notify(lager_event, {log, lager_util:level_to_num(Level), Time, Msg}).
+ gen_event:sync_notify(lager_event, {log, lager_util:level_to_num(Level), Time, Msg}).
log(Level, Module, Function, Line, Pid, {{Y, M, D}, {H, Mi, S}}, Format, Args) ->
Time = io_lib:format("~b-~b-~b ~b:~b:~b", [Y, M, D, H, Mi, S]),
Msg = io_lib:format("[~p] ~p@~p:~p:~p ~s", [Level, Pid, Module,
Function, Line, io_lib:format(Format, Args)]),
- gen_event:notify(lager_event, {log, lager_util:level_to_num(Level), Time, Msg}).
+ gen_event:sync_notify(lager_event, {log, lager_util:level_to_num(Level), Time, Msg}).
set_loglevel(Handler, Level) when is_atom(Level) ->
gen_server:call(?MODULE, {set_loglevel, Handler, Level}).
Please sign in to comment.
Something went wrong with that request. Please try again.