summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert@lshift.net>2008-09-04 11:12:11 +0100
committerHubert Plociniczak <hubert@lshift.net>2008-09-04 11:12:11 +0100
commit61dfd8b50862e44ec9f667690dfa082d3c887c70 (patch)
treec97a213743f97bc78d40141a3e54ffa5be4b332c
parent38616df03ffeac5984a3edd515e89de7be5b8db6 (diff)
downloadrabbitmq-server-61dfd8b50862e44ec9f667690dfa082d3c887c70.tar.gz
Moved log configuration to start/0,
throw more informative errors
-rw-r--r--src/rabbit.erl25
-rw-r--r--src/rabbit_tests.erl4
2 files changed, 19 insertions, 10 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 2d309c05..4cb11f4f 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -67,6 +67,7 @@
start() ->
try
+ ok = ensure_working_log_handlers(),
ok = rabbit_mnesia:ensure_mnesia_dir(),
ok = start_applications(?APPS)
after
@@ -148,9 +149,7 @@ start(normal, []) ->
apply(M, F, A),
io:format("done~n")
end,
- [{"log configuration",
- fun () -> ok = ensure_working_log_handlers() end},
- {"database",
+ [{"database",
fun () -> ok = rabbit_mnesia:init() end},
{"core processes",
fun () ->
@@ -253,16 +252,26 @@ ensure_working_log_handlers() ->
ensure_working_log_handler(OldFHandler, NewFHandler, TTYHandler,
LogLocation, Handlers) ->
- case LogLocation of
+ case LogLocation of
undefined -> ok;
- tty -> true = lists:member(TTYHandler, Handlers), ok;
+ tty -> case lists:member(TTYHandler, Handlers) of
+ true -> ok;
+ false ->
+ throw({error, {cannot_log_to_tty,
+ TTYHandler, not_installed}})
+ end;
_ -> case lists:member(NewFHandler, Handlers) of
true -> ok;
- false -> rotate_logs(LogLocation, "",
- OldFHandler, NewFHandler)
+ false -> case rotate_logs(LogLocation, "",
+ OldFHandler, NewFHandler) of
+ ok -> ok;
+ {error, Reason} ->
+ throw({error, {cannot_log_to_file,
+ LogLocation, Reason}})
+ end
end
end.
-
+
maybe_insert_default_data() ->
case rabbit_mnesia:is_db_empty() of
true -> insert_default_data();
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index 34eebec1..64425ee7 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -237,7 +237,7 @@ test_log_management_during_startup() ->
ok = delete_log_handlers([sasl_report_tty_h]),
ok = case catch control_action(start_app, []) of
ok -> exit(got_success_but_expected_failure);
- {error, {cannot_start_application, rabbit, _}} -> ok
+ {error, {cannot_log_to_tty, _, _}} -> ok
end,
%% fix sasl logging
@@ -253,7 +253,7 @@ test_log_management_during_startup() ->
ok = add_log_handlers([{error_logger_file_h, MainLog}]),
ok = case catch control_action(start_app, []) of
ok -> exit(got_success_but_expected_failure);
- {error, {cannot_start_application, rabbit, _}} -> ok
+ {error, {cannot_log_to_file, _, _}} -> ok
end,
%% cleanup