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>
diff --git a/src/setup.erl b/src/setup.erl
index b227856..2118349 100644
--- a/src/setup.erl
+++ b/src/setup.erl
@@ -99,7 +99,7 @@
{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 @@
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_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 @@
% 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 de1bff5..f84112b 100644
--- a/src/setup_httpd.erl
+++ b/src/setup_httpd.erl
@@ -19,7 +19,7 @@
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("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 @@
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 @@
end;
handle_action(_, _) ->
- io:format("~ninvalid_action: ~n", []),
+ couch_log:notice("invalid_action: ~n", []),
{error, <<"Invalid Action'">>}.
@@ -122,6 +122,6 @@
{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.