summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Kowalski <robertkowalski@apache.org>2015-06-23 11:42:12 +0200
committerRobert Kowalski <robertkowalski@apache.org>2015-06-24 15:38:30 +0200
commitaa17a557bb6ad207c1d4e42d0e74ef81f1d45f2c (patch)
tree7b2f98db7efbf69354fd40f29dc44a25f277d1a4
parentf4fd3face65ff2f9c5365cfa96bedd352f2906b8 (diff)
downloadcouchdb-aa17a557bb6ad207c1d4e42d0e74ef81f1d45f2c.tar.gz
use couch_log instead of io:format
PR: #2 PR-URL: https://github.com/apache/couchdb-setup/pull/2 Reviewed-By: Jan Lehnardt <jan@apache.org> Reviewed-By: Alexander Shorin <kxepal@apache.org>
-rw-r--r--src/setup.erl8
-rw-r--r--src/setup_httpd.erl16
2 files changed, 12 insertions, 12 deletions
diff --git a/src/setup.erl b/src/setup.erl
index b2278568b..211834928 100644
--- a/src/setup.erl
+++ b/src/setup.erl
@@ -99,7 +99,7 @@ enable_cluster_http(Options) ->
{ok, "201", _, _} ->
ok;
Else ->
- io:format("~nsend_req: ~p~n", [Else]),
+ couch_log:notice("send_req: ~p~n", [Else]),
{error, Else}
end.
@@ -141,7 +141,7 @@ enable_cluster_int(Options, no) ->
Port ->
config:set("httpd", "port", integer_to_list(Port))
end,
- io:format("~nEnable Cluster: ~p~n", [Options]).
+ couch_log:notice("Enable Cluster: ~p~n", [Options]).
%cluster_state:set(enabled).
maybe_set_admin(Username, Password) ->
@@ -168,7 +168,7 @@ add_node(Options) ->
add_node_int(_Options, no) ->
{error, cluster_not_enabled};
add_node_int(Options, ok) ->
- io:format("~nadd node: ~p~n", [Options]),
+ couch_log:notice("add node: ~p~n", [Options]),
ErlangCookie = erlang:get_cookie(),
% POST to nodeB/_setup
@@ -198,7 +198,7 @@ add_node_int(Options, ok) ->
% when done, PUT :5986/nodes/nodeB
create_node_doc(Host, Port);
Else ->
- io:format("~nsend_req: ~p~n", [Else]),
+ couch_log:notice("send_req: ~p~n", [Else]),
Else
end.
diff --git a/src/setup_httpd.erl b/src/setup_httpd.erl
index de1bff5fa..f84112b21 100644
--- a/src/setup_httpd.erl
+++ b/src/setup_httpd.erl
@@ -19,7 +19,7 @@ handle_setup_req(#httpd{method='POST'}=Req) ->
ok = chttpd:verify_is_server_admin(Req),
couch_httpd:validate_ctype(Req, "application/json"),
Setup = get_body(Req),
- io:format("~nSetup: ~p~n", [Setup]),
+ couch_log:notice("Setup: ~p~n", [Setup]),
Action = binary_to_list(couch_util:get_value(<<"action">>, Setup, <<"missing">>)),
case handle_action(Action, Setup) of
ok ->
@@ -68,17 +68,17 @@ handle_action("enable_cluster", Setup) ->
handle_action("finish_cluster", Setup) ->
- io:format("~nffinish_cluster: ~p~n", [Setup]),
+ couch_log:notice("finish_cluster: ~p~n", [Setup]),
case setup:finish_cluster() of
{error, cluster_finished} ->
{error, <<"Cluster is already finished">>};
Else ->
- io:format("~nElse: ~p~n", [Else]),
+ couch_log:notice("Else: ~p~n", [Else]),
ok
end;
handle_action("add_node", Setup) ->
- io:format("~nadd_node: ~p~n", [Setup]),
+ couch_log:notice("add_node: ~p~n", [Setup]),
Options = get_options([
{username, <<"username">>},
@@ -99,10 +99,10 @@ handle_action("add_node", Setup) ->
end;
handle_action("remove_node", Setup) ->
- io:format("~nremove_node: ~p~n", [Setup]);
+ couch_log:notice("remove_node: ~p~n", [Setup]);
handle_action("receive_cookie", Setup) ->
- io:format("~nreceive_cookie: ~p~n", [Setup]),
+ couch_log:notice("receive_cookie: ~p~n", [Setup]),
Options = get_options([
{cookie, <<"cookie">>}
], Setup),
@@ -113,7 +113,7 @@ handle_action("receive_cookie", Setup) ->
end;
handle_action(_, _) ->
- io:format("~ninvalid_action: ~n", []),
+ couch_log:notice("invalid_action: ~n", []),
{error, <<"Invalid Action'">>}.
@@ -122,6 +122,6 @@ get_body(Req) ->
{Body} ->
Body;
Else ->
- io:format("~nBody Fail: ~p~n", [Else]),
+ couch_log:notice("Body Fail: ~p~n", [Else]),
couch_httpd:send_error(Req, 400, <<"bad_request">>, <<"Missing JSON body'">>)
end.