Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
use couch_log instead of io:format
PR: #2
PR-URL: #2
Reviewed-By: Jan Lehnardt <jan@apache.org>
Reviewed-By: Alexander Shorin <kxepal@apache.org>
  • Loading branch information
robertkowalski committed Jun 24, 2015
1 parent f4fd3fa commit aa17a557bb6ad207c1d4e42d0e74ef81f1d45f2c
Showing 2 changed files with 12 additions and 12 deletions.
@@ -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.

@@ -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.

0 comments on commit aa17a55

Please sign in to comment.