Permalink
Browse files

Default the error_logger redirect to be on, log to the 'log' dir

  • Loading branch information...
1 parent 2128752 commit 0859c90b06aedcf248aa52a2799ec4100064642b @Vagabond Vagabond committed Jun 30, 2011
Showing with 12 additions and 7 deletions.
  1. +6 −2 README.org
  2. +5 −5 src/lager.erl
  3. +1 −0 test/lager_test_backend.erl
View
@@ -64,8 +64,12 @@
* Error logger integration
Lager is also supplied with a error_logger handler module that translates
traditional erlang error messages into a friendlier format and sends them into
- lager itself to be treated like a regular lager log call. To enable this, set
- the lager application variable `error_logger_redirect' to `true'.
+ lager itself to be treated like a regular lager log call. To disable this, set
+ the lager application variable `error_logger_redirect' to `false'.
+
+ The error_logger handler will also log more complete error messages (protected
+ with use of trunc_io) to a "crash log" which can be referred to for further
+ information.
* Runtime loglevel changes
You can change the log level of any lager backend at runtime by doing the
View
@@ -35,7 +35,7 @@ start_link() ->
Handlers = case application:get_env(lager, handlers) of
undefined ->
[{lager_console_backend, [info]},
- {lager_file_backend, [{"error.log", error}, {"console.log", info}]}];
+ {lager_file_backend, [{"log/error.log", error}, {"log/console.log", info}]}];
{ok, Val} ->
Val
end,
@@ -45,7 +45,7 @@ start() ->
Handlers = case application:get_env(lager, handlers) of
undefined ->
[{lager_console_backend, [info]},
- {lager_file_backend, [{"error.log", error}, {"console.log", info}]}];
+ {lager_file_backend, [{"log/error.log", error}, {"log/console.log", info}]}];
{ok, Val} ->
Val
end,
@@ -100,13 +100,13 @@ init([Handlers]) ->
MinLog = minimum_log_level(get_log_levels()),
lager_mochiglobal:put(loglevel, MinLog),
case application:get_env(lager, error_logger_redirect) of
- {ok, true} ->
+ {ok, false} ->
+ {ok, #state{}};
+ _ ->
gen_event:add_sup_handler(error_logger, error_logger_lager_h, []),
%% TODO allow user to whitelist handlers to not be removed
[gen_event:delete_handler(error_logger, X, {stop_please, ?MODULE}) ||
X <- gen_event:which_handlers(error_logger) -- [error_logger_lager_h]],
- {ok, #state{}};
- _ ->
{ok, #state{}}
end.
@@ -173,6 +173,7 @@ lager_test_() ->
setup() ->
application:load(lager),
application:set_env(lager, handlers, [{?MODULE, [info]}]),
+ application:set_env(lager, error_logger_redirect, false),
application:start(lager).
cleanup(_) ->

0 comments on commit 0859c90

Please sign in to comment.