Repository: couchdb-couch Updated Branches: refs/heads/master a7dc712e2 -> d28af1852
Use couch_log instead of ?LOG_* Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/d28af185 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/d28af185 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/d28af185 Branch: refs/heads/master Commit: d28af185295d4618b489c050bcc71407e89891f1 Parents: a7dc712 Author: Alexander Shorin <kxe...@apache.org> Authored: Wed Sep 24 01:07:18 2014 +0400 Committer: Alexander Shorin <kxe...@apache.org> Committed: Thu Sep 25 00:40:13 2014 +0400 ---------------------------------------------------------------------- src/couch_compaction_daemon.erl | 48 ++++++++++++++++---------------- src/couch_db.erl | 13 +++++---- src/couch_db_updater.erl | 25 +++++++++-------- src/couch_doc.erl | 10 +++---- src/couch_drv.erl | 2 +- src/couch_external_manager.erl | 4 +-- src/couch_external_server.erl | 9 +++--- src/couch_file.erl | 4 +-- src/couch_httpd.erl | 43 +++++++++++++++-------------- src/couch_httpd_auth.erl | 9 +++--- src/couch_httpd_db.erl | 2 +- src/couch_httpd_misc_handlers.erl | 6 ++-- src/couch_httpd_oauth.erl | 34 +++++++++++++---------- src/couch_httpd_rewrite.erl | 5 ++-- src/couch_httpd_vhost.erl | 2 +- src/couch_native_process.erl | 12 ++++---- src/couch_os_daemons.erl | 50 ++++++++++++++++++---------------- src/couch_os_process.erl | 24 ++++++++-------- src/couch_proc_manager.erl | 6 ++-- src/couch_server.erl | 13 +++++---- src/couch_sup.erl | 2 +- src/couch_task_status.erl | 2 +- 22 files changed, 175 insertions(+), 150 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_compaction_daemon.erl ---------------------------------------------------------------------- diff --git a/src/couch_compaction_daemon.erl b/src/couch_compaction_daemon.erl index 5a1ef7d..12b10d8 100644 --- a/src/couch_compaction_daemon.erl +++ b/src/couch_compaction_daemon.erl @@ -168,14 +168,14 @@ maybe_compact_db(DbName, Config) -> false -> maybe_compact_views(DbName, DDocNames, Config) end; {error, timeout} -> - ?LOG_INFO("Compaction daemon - canceling compaction " + couch_log:info("Compaction daemon - canceling compaction " "for databaes `~s` because exceeded the allowed time.", [DbName]), ok = couch_db:cancel_compact(Db), couch_db:close(Db); {error, Reason} -> couch_db:close(Db), - ?LOG_ERROR("Compaction daemon - an error ocurred while" + couch_log:error("Compaction daemon - an error ocurred while" " compacting the database `~s`: ~p", [DbName, Reason]) end, case ViewsMonRef of @@ -243,14 +243,14 @@ maybe_compact_view(DbName, GroupId, Config) -> {'DOWN', MonRef, process, _, normal} -> ok; {'DOWN', MonRef, process, _, Reason} -> - ?LOG_ERROR("Compaction daemon - an error ocurred while compacting" - " the view group `~s` from database `~s`: ~p", - [GroupId, DbName, Reason]), + couch_log:error("Compaction daemon - an error ocurred" + " while compacting the view group `~s` from database " + "`~s`: ~p", [GroupId, DbName, Reason]), ok after TimeLeft -> - ?LOG_INFO("Compaction daemon - canceling the compaction for the " - "view group `~s` of the database `~s` because it's exceeding" - " the allowed period.", [GroupId, DbName]), + couch_log:info("Compaction daemon - canceling the compaction" + " for the view group `~s` of the database `~s` because it's" + " exceeding the allowed period.", [GroupId, DbName]), erlang:demonitor(MonRef, [flush]), ok = couch_mrview:cancel_compaction(DbName, DDocId), timeout @@ -259,7 +259,7 @@ maybe_compact_view(DbName, GroupId, Config) -> ok end; Error -> - ?LOG_ERROR("Error opening view group `~s` from database `~s`: ~p", + couch_log:error("Error opening view group `~s` from database `~s`: ~p", [GroupId, DbName, Error]), ok end. @@ -300,8 +300,9 @@ can_db_compact(#config{db_frag = Threshold} = Config, Db) -> true -> {ok, DbInfo} = couch_db:get_db_info(Db), {Frag, SpaceRequired} = frag(DbInfo), - ?LOG_DEBUG("Fragmentation for database `~s` is ~p%, estimated space for" - " compaction is ~p bytes.", [Db#db.name, Frag, SpaceRequired]), + couch_log:debug("Fragmentation for database `~s` is ~p%, estimated" + " space for compaction is ~p bytes.", + [Db#db.name, Frag, SpaceRequired]), case check_frag(Threshold, Frag) of false -> false; @@ -311,10 +312,10 @@ can_db_compact(#config{db_frag = Threshold} = Config, Db) -> true -> true; false -> - ?LOG_WARN("Compaction daemon - skipping database `~s` " + couch_log:warning("Compaction daemon - skipping database `~s` " "compaction: the estimated necessary disk space is about ~p" " bytes but the currently available disk space is ~p bytes.", - [Db#db.name, SpaceRequired, Free]), + [Db#db.name, SpaceRequired, Free]), false end end @@ -330,8 +331,8 @@ can_view_compact(Config, DbName, GroupId, GroupInfo) -> false; false -> {Frag, SpaceRequired} = frag(GroupInfo), - ?LOG_DEBUG("Fragmentation for view group `~s` (database `~s`) is " - "~p%, estimated space for compaction is ~p bytes.", + couch_log:debug("Fragmentation for view group `~s` (database `~s`)" + " is ~p%, estimated space for compaction is ~p bytes.", [GroupId, DbName, Frag, SpaceRequired]), case check_frag(Config#config.view_frag, Frag) of false -> @@ -342,10 +343,10 @@ can_view_compact(Config, DbName, GroupId, GroupInfo) -> true -> true; false -> - ?LOG_WARN("Compaction daemon - skipping view group `~s` " - "compaction (database `~s`): the estimated necessary " - "disk space is about ~p bytes but the currently available" - " disk space is ~p bytes.", + couch_log:warning("Compaction daemon - skipping view group" + " `~s` compaction (database `~s`): the estimated" + " necessary disk space is about ~p bytes" + " but the currently available disk space is ~p bytes.", [GroupId, DbName, SpaceRequired, Free]), false end @@ -414,12 +415,13 @@ parse_config(DbName, ConfigString) -> {ok, Conf} -> {ok, Conf}; incomplete_period -> - ?LOG_ERROR("Incomplete period ('to' or 'from' missing) in the compaction" - " configuration for database `~s`", [DbName]), + couch_log:error("Incomplete period ('to' or 'from' missing)" + " in the compaction configuration for database `~s`", + [DbName]), error; _ -> - ?LOG_ERROR("Invalid compaction configuration for database " - "`~s`: `~s`", [DbName, ConfigString]), + couch_log:error("Invalid compaction configuration for database " + "`~s`: `~s`", [DbName, ConfigString]), error end. http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_db.erl ---------------------------------------------------------------------- diff --git a/src/couch_db.erl b/src/couch_db.erl index b3663fe..5d4619a 100644 --- a/src/couch_db.erl +++ b/src/couch_db.erl @@ -57,7 +57,8 @@ open_db_file(Filepath, Options) -> % crashed during the file switch. case couch_file:open(Filepath ++ ".compact", [nologifmissing]) of {ok, Fd} -> - ?LOG_INFO("Found ~s~s compaction file, using as primary storage.", [Filepath, ".compact"]), + couch_log:info("Found ~s~s compaction file, using as primary" + " storage.", [Filepath, ".compact"]), ok = file:rename(Filepath ++ ".compact", Filepath), ok = couch_file:sync(Fd), {ok, Fd}; @@ -430,7 +431,9 @@ check_is_member(#db{user_ctx=#user_ctx{name=Name,roles=Roles}=UserCtx}=Db) -> WithAdminRoles -> % same list, not an reader role case ReaderNames -- [Name] of ReaderNames -> % same names, not a reader - ?LOG_DEBUG("Not a reader: UserCtx ~p vs Names ~p Roles ~p",[UserCtx, ReaderNames, WithAdminRoles]), + couch_log:debug("Not a reader: UserCtx ~p" + " vs Names ~p Roles ~p", + [UserCtx, ReaderNames, WithAdminRoles]), throw({unauthorized, <<"You are not authorized to access this db.">>}); _ -> ok @@ -603,7 +606,7 @@ load_validation_funs(#db{main_pid=Pid, name = <<"shards/", _/binary>>}=Db) -> gen_server:cast(Pid, {load_validation_funs, Funs}), Funs; {'DOWN', Ref, _, _, Reason} -> - ?LOG_ERROR("could not load validation funs ~p", [Reason]), + couch_log:error("could not load validation funs ~p", [Reason]), throw(internal_server_error) end; load_validation_funs(#db{main_pid=Pid}=Db) -> @@ -966,8 +969,8 @@ set_commit_option(Options) -> {_, "false"} -> [full_commit|Options]; {_, Else} -> - ?LOG_ERROR("[couchdb] delayed_commits setting must be true/false, not ~p", - [Else]), + couch_log:error("[couchdb] delayed_commits setting must be true/false," + " not ~p", [Else]), [full_commit|Options] end. http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_db_updater.erl ---------------------------------------------------------------------- diff --git a/src/couch_db_updater.erl b/src/couch_db_updater.erl index 23bc5cc..93ee6e9 100644 --- a/src/couch_db_updater.erl +++ b/src/couch_db_updater.erl @@ -209,7 +209,7 @@ handle_cast({load_validation_funs, ValidationFuns}, Db) -> handle_cast(start_compact, Db) -> case Db#db.compactor_pid of nil -> - ?LOG_INFO("Starting compaction for db \"~s\"", [Db#db.name]), + couch_log:info("Starting compaction for db \"~s\"", [Db#db.name]), Pid = spawn_link(fun() -> start_copy_compact(Db) end), Db2 = Db#db{compactor_pid=Pid}, ok = gen_server:call(couch_server, {db_updated, Db2}, infinity), @@ -242,8 +242,8 @@ handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath}=Db) -> revs_limit = Db#db.revs_limit }), - ?LOG_DEBUG("CouchDB swapping files ~s and ~s.", - [Filepath, CompactFilepath]), + couch_log:debug("CouchDB swapping files ~s and ~s.", + [Filepath, CompactFilepath]), ok = file:rename(CompactFilepath, Filepath ++ ".compact"), RootDir = config:get("couchdb", "database_dir", "."), couch_file:delete(RootDir, Filepath), @@ -255,12 +255,12 @@ handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath}=Db) -> NewDb3 = refresh_validate_doc_funs(NewDb2), ok = gen_server:call(couch_server, {db_updated, NewDb3}, infinity), couch_event:notify(NewDb3#db.name, compacted), - ?LOG_INFO("Compaction for db \"~s\" completed.", [Db#db.name]), + couch_log:info("Compaction for db \"~s\" completed.", [Db#db.name]), {noreply, NewDb3#db{compactor_pid=nil}}; false -> - ?LOG_INFO("Compaction file still behind main file " - "(update seq=~p. compact update seq=~p). Retrying.", - [Db#db.update_seq, NewSeq]), + couch_log:info("Compaction file still behind main file " + "(update seq=~p. compact update seq=~p). Retrying.", + [Db#db.update_seq, NewSeq]), close_db(NewDb), Pid = spawn_link(fun() -> start_copy_compact(Db) end), Db2 = Db#db{compactor_pid=Pid}, @@ -269,7 +269,8 @@ handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath}=Db) -> end; handle_cast(Msg, #db{name = Name} = Db) -> - ?LOG_ERROR("Database `~s` updater received unexpected cast: ~p", [Name, Msg]), + couch_log:error("Database `~s` updater received unexpected cast: ~p", + [Name, Msg]), {stop, Msg, Db}. @@ -331,7 +332,7 @@ handle_info({'EXIT', _Pid, normal}, Db) -> handle_info({'EXIT', _Pid, Reason}, Db) -> {stop, Reason, Db}; handle_info({'DOWN', Ref, _, _, Reason}, #db{fd_monitor=Ref, name=Name} = Db) -> - ?LOG_ERROR("DB ~s shutting down - Fd ~p", [Name, Reason]), + couch_log:error("DB ~s shutting down - Fd ~p", [Name, Reason]), {stop, normal, Db#db{fd=undefined, fd_monitor=closed}}. code_change(_OldVsn, State, _Extra) -> @@ -652,8 +653,8 @@ flush_trees(#db{fd = Fd} = Db, % Fd where the attachments were written to is not the same % as our Fd. This can happen when a database is being % switched out during a compaction. - ?LOG_DEBUG("File where the attachments are written has" - " changed. Possibly retrying.", []), + couch_log:debug("File where the attachments are written has" + " changed. Possibly retrying.", []), throw(retry) end, ExternalSize = ?term_size(Summary), @@ -1182,7 +1183,7 @@ copy_compact(Db, NewDb0, Retry) -> start_copy_compact(#db{}=Db) -> erlang:put(io_priority, {db_compact, Db#db.name}), #db{name=Name, filepath=Filepath, options=Options, header=Header} = Db, - ?LOG_DEBUG("Compaction process spawned for db \"~s\"", [Name]), + couch_log:debug("Compaction process spawned for db \"~s\"", [Name]), {ok, NewDb, DName, DFd, MFd, Retry} = open_compaction_files(Name, Header, Filepath, Options), http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_doc.erl ---------------------------------------------------------------------- diff --git a/src/couch_doc.erl b/src/couch_doc.erl index 3813a4b..de3141d 100644 --- a/src/couch_doc.erl +++ b/src/couch_doc.erl @@ -167,7 +167,7 @@ validate_docid(Id) when is_binary(Id) -> _Else -> ok end; validate_docid(Id) -> - ?LOG_DEBUG("Document id is not a string: ~p", [Id]), + couch_log:debug("Document id is not a string: ~p", [Id]), throw({bad_request, <<"Document id must be a string">>}). transfer_fields([], #doc{body=Fields}=Doc) -> @@ -472,12 +472,12 @@ doc_from_multi_part_stream(ContentType, DataFun, Ref) -> {'DOWN', ParserRef, _, _, normal} -> ok; {'DOWN', ParserRef, process, Parser, {{nocatch, {Error, Msg}}, _}} -> - ?LOG_ERROR("Multipart streamer ~p died with reason ~p", - [ParserRef, Msg]), + couch_log:error("Multipart streamer ~p died with reason ~p", + [ParserRef, Msg]), throw({Error, Msg}); {'DOWN', ParserRef, _, _, Reason} -> - ?LOG_ERROR("Multipart streamer ~p died with reason ~p", - [ParserRef, Reason]), + couch_log:error("Multipart streamer ~p died with reason ~p", + [ParserRef, Reason]), throw({error, Reason}) end. http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_drv.erl ---------------------------------------------------------------------- diff --git a/src/couch_drv.erl b/src/couch_drv.erl index 4424114..0379264 100644 --- a/src/couch_drv.erl +++ b/src/couch_drv.erl @@ -29,7 +29,7 @@ init([]) -> ok -> {ok, nil}; {error, already_loaded} -> - ?LOG_INFO("~p reloading couch_icu_driver", [?MODULE]), + couch_log:info("~p reloading couch_icu_driver", [?MODULE]), ok = erl_ddll:reload(LibDir, "couch_icu_driver"), {ok, nil}; {error, Error} -> http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_external_manager.erl ---------------------------------------------------------------------- diff --git a/src/couch_external_manager.erl b/src/couch_external_manager.erl index d2fa1ea..51c6125 100644 --- a/src/couch_external_manager.erl +++ b/src/couch_external_manager.erl @@ -90,14 +90,14 @@ handle_cast(_Whatever, State) -> {noreply, State}. handle_info({'EXIT', Pid, normal}, Handlers) -> - ?LOG_INFO("EXTERNAL: Server ~p terminated normally", [Pid]), + couch_log:info("EXTERNAL: Server ~p terminated normally", [Pid]), % The process terminated normally without us asking - Remove Pid from the % handlers table so we don't attempt to reuse it ets:match_delete(Handlers, {'_', Pid}), {noreply, Handlers}; handle_info({'EXIT', Pid, Reason}, Handlers) -> - ?LOG_INFO("EXTERNAL: Server ~p died. (reason: ~p)", [Pid, Reason]), + couch_log:info("EXTERNAL: Server ~p died. (reason: ~p)", [Pid, Reason]), % Remove Pid from the handlers table so we don't try closing % it a second time in terminate/2. ets:match_delete(Handlers, {'_', Pid}), http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_external_server.erl ---------------------------------------------------------------------- diff --git a/src/couch_external_server.erl b/src/couch_external_server.erl index 40d9113..d5560b0 100644 --- a/src/couch_external_server.erl +++ b/src/couch_external_server.erl @@ -38,8 +38,8 @@ execute(Pid, JsonReq) -> % Gen Server Handlers init([Name, Command]) -> - ?LOG_INFO("EXTERNAL: Starting process for: ~s", [Name]), - ?LOG_INFO("COMMAND: ~s", [Command]), + couch_log:info("EXTERNAL: Starting process for: ~s", [Name]), + couch_log:info("COMMAND: ~s", [Command]), process_flag(trap_exit, true), Timeout = list_to_integer(config:get("couchdb", "os_process_timeout", "5000")), @@ -63,11 +63,12 @@ handle_info(restart_config_listener, State) -> handle_info({'EXIT', _Pid, normal}, State) -> {noreply, State}; handle_info({'EXIT', Pid, Reason}, {Name, Command, Pid}) -> - ?LOG_INFO("EXTERNAL: Process for ~s exiting. (reason: ~w)", [Name, Reason]), + couch_log:info("EXTERNAL: Process for ~s exiting. (reason: ~w)", + [Name, Reason]), {stop, Reason, {Name, Command, Pid}}. handle_cast(stop, {Name, Command, Pid}) -> - ?LOG_INFO("EXTERNAL: Shutting down ~s", [Name]), + couch_log:info("EXTERNAL: Shutting down ~s", [Name]), exit(Pid, normal), {stop, normal, {Name, Command, Pid}}; handle_cast(_Whatever, State) -> http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_file.erl ---------------------------------------------------------------------- diff --git a/src/couch_file.erl b/src/couch_file.erl index 19fb72e..3ebf608 100644 --- a/src/couch_file.erl +++ b/src/couch_file.erl @@ -69,8 +69,8 @@ open(Filepath, Options) -> case {lists:member(nologifmissing, Options), Reason} of {true, enoent} -> ok; _ -> - ?LOG_ERROR("Could not open file ~s: ~s", - [Filepath, file:format_error(Reason)]) + couch_log:error("Could not open file ~s: ~s", + [Filepath, file:format_error(Reason)]) end, Error end; http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_httpd.erl ---------------------------------------------------------------------- diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl index bebc3b8..d298b94 100644 --- a/src/couch_httpd.erl +++ b/src/couch_httpd.erl @@ -53,7 +53,7 @@ start_link(https) -> case (couch_util:get_value(keyfile, ServerOpts0) == nil orelse couch_util:get_value(certfile, ServerOpts0) == nil) of true -> - io:format("SSL enabled but PEM certificates are missing.", []), + couch_log:error("SSL enabled but PEM certificates are missing", []), throw({error, missing_certs}); false -> ok @@ -146,7 +146,7 @@ start_link(Name, Options) -> {ok, MochiPid} -> {ok, MochiPid}; {error, Reason} -> - io:format("Failure to start Mochiweb: ~s~n",[Reason]), + couch_log:error("Failure to start Mochiweb: ~s~n", [Reason]), throw({error, Reason}) end. @@ -228,7 +228,7 @@ handle_request_int(MochiReq, DefaultFun, {FirstPart, _, _} -> list_to_binary(FirstPart) end, - ?LOG_DEBUG("~p ~s ~p from ~p~nHeaders: ~p", [ + couch_log:debug("~p ~s ~p from ~p~nHeaders: ~p", [ MochiReq:get(method), RawUri, MochiReq:get(version), @@ -254,7 +254,8 @@ handle_request_int(MochiReq, DefaultFun, "TRACE", "CONNECT", "COPY"]) of true -> - ?LOG_INFO("MethodOverride: ~s (real method was ~s)", [MethodOverride, Method1]), + couch_log:info("MethodOverride: ~s (real method was ~s)", + [MethodOverride, Method1]), case Method1 of 'POST' -> couch_util:to_existing_atom(MethodOverride); _ -> @@ -308,21 +309,22 @@ handle_request_int(MochiReq, DefaultFun, throw:{http_head_abort, Resp0} -> {ok, Resp0}; throw:{invalid_json, S} -> - ?LOG_ERROR("attempted upload of invalid JSON (set log_level to debug to log it)", []), - ?LOG_DEBUG("Invalid JSON: ~p",[S]), + couch_log:error("attempted upload of invalid JSON" + " (set log_level to debug to log it)", []), + couch_log:debug("Invalid JSON: ~p",[S]), send_error(HttpReq, {bad_request, invalid_json}); throw:unacceptable_encoding -> - ?LOG_ERROR("unsupported encoding method for the response", []), + couch_log:error("unsupported encoding method for the response", []), send_error(HttpReq, {not_acceptable, "unsupported encoding"}); throw:bad_accept_encoding_value -> - ?LOG_ERROR("received invalid Accept-Encoding header", []), + couch_log:error("received invalid Accept-Encoding header", []), send_error(HttpReq, bad_request); exit:normal -> exit(normal); exit:snappy_nif_not_loaded -> ErrorReason = "To access the database or view index, Apache CouchDB" - " must be built with Erlang OTP R13B04 or higher.", - ?LOG_ERROR("~s", [ErrorReason]), + " must be built with Erlang OTP R13B04 or higher.", + couch_log:error("~s", [ErrorReason]), send_error(HttpReq, {bad_otp_release, ErrorReason}); exit:{body_too_large, _} -> send_error(HttpReq, request_entity_too_large); @@ -330,23 +332,24 @@ handle_request_int(MochiReq, DefaultFun, send_error(HttpReq, request_uri_too_long); throw:Error -> Stack = erlang:get_stacktrace(), - ?LOG_DEBUG("Minor error in HTTP request: ~p",[Error]), - ?LOG_DEBUG("Stacktrace: ~p",[Stack]), + couch_log:debug("Minor error in HTTP request: ~p",[Error]), + couch_log:debug("Stacktrace: ~p",[Stack]), send_error(HttpReq, Error); error:badarg -> Stack = erlang:get_stacktrace(), - ?LOG_ERROR("Badarg error in HTTP request",[]), - ?LOG_INFO("Stacktrace: ~p",[Stack]), + couch_log:error("Badarg error in HTTP request",[]), + couch_log:info("Stacktrace: ~p",[Stack]), send_error(HttpReq, badarg); error:function_clause -> Stack = erlang:get_stacktrace(), - ?LOG_ERROR("function_clause error in HTTP request",[]), - ?LOG_INFO("Stacktrace: ~p",[Stack]), + couch_log:error("function_clause error in HTTP request",[]), + couch_log:info("Stacktrace: ~p",[Stack]), send_error(HttpReq, function_clause); Tag:Error -> Stack = erlang:get_stacktrace(), - ?LOG_ERROR("Uncaught error in HTTP request: ~p",[{Tag, Error}]), - ?LOG_INFO("Stacktrace: ~p",[Stack]), + couch_log:error("Uncaught error in HTTP request: ~p", + [{Tag, Error}]), + couch_log:info("Stacktrace: ~p",[Stack]), send_error(HttpReq, Error) end, RequestTime = round(timer:now_diff(os:timestamp(), Begin)/1000), @@ -694,9 +697,9 @@ send_response(#httpd{mochi_req=MochiReq}=Req, Code, Headers, Body) -> couch_stats:increment_counter([couchdb, httpd_status_codes, Code]), Headers1 = http_1_0_keep_alive(MochiReq, Headers), if Code >= 500 -> - ?LOG_ERROR("httpd ~p error response:~n ~s", [Code, Body]); + couch_log:error("httpd ~p error response:~n ~s", [Code, Body]); Code >= 400 -> - ?LOG_DEBUG("httpd ~p error response:~n ~s", [Code, Body]); + couch_log:debug("httpd ~p error response:~n ~s", [Code, Body]); true -> ok end, Headers2 = Headers1 ++ server_header() ++ http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_httpd_auth.erl ---------------------------------------------------------------------- diff --git a/src/couch_httpd_auth.erl b/src/couch_httpd_auth.erl index ba5c798..7c55a2b 100644 --- a/src/couch_httpd_auth.erl +++ b/src/couch_httpd_auth.erl @@ -188,7 +188,7 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req, AuthModule) -> CurrentTime = make_cookie_time(), case config:get("couch_httpd_auth", "secret", nil) of nil -> - ?LOG_DEBUG("cookie auth secret is not set",[]), + couch_log:debug("cookie auth secret is not set",[]), Req; SecretStr -> Secret = ?l2b(SecretStr), @@ -201,13 +201,14 @@ cookie_authentication_handler(#httpd{mochi_req=MochiReq}=Req, AuthModule) -> Hash = ?l2b(HashStr), Timeout = list_to_integer( config:get("couch_httpd_auth", "timeout", "600")), - ?LOG_DEBUG("timeout ~p", [Timeout]), + couch_log:debug("timeout ~p", [Timeout]), case (catch erlang:list_to_integer(TimeStr, 16)) of TimeStamp when CurrentTime < TimeStamp + Timeout -> case couch_passwords:verify(ExpectedHash, Hash) of true -> TimeLeft = TimeStamp + Timeout - CurrentTime, - ?LOG_DEBUG("Successful cookie auth as: ~p", [User]), + couch_log:debug("Successful cookie auth as: ~p", + [User]), Req#httpd{user_ctx=#user_ctx{ name=?l2b(User), roles=couch_util:get_value(<<"roles">>, UserProps, []) @@ -279,7 +280,7 @@ handle_session_req(#httpd{method='POST', mochi_req=MochiReq}=Req, AuthModule) -> end, UserName = ?l2b(couch_util:get_value("name", Form, "")), Password = ?l2b(couch_util:get_value("password", Form, "")), - ?LOG_DEBUG("Attempt Login: ~s",[UserName]), + couch_log:debug("Attempt Login: ~s",[UserName]), UserProps = case AuthModule:get_user_creds(UserName) of nil -> []; Result -> Result http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_httpd_db.erl ---------------------------------------------------------------------- diff --git a/src/couch_httpd_db.erl b/src/couch_httpd_db.erl index 463d369..13e2c44 100644 --- a/src/couch_httpd_db.erl +++ b/src/couch_httpd_db.erl @@ -748,7 +748,7 @@ update_doc(Req, Db, DocId, #doc{deleted=Deleted}=Doc, Headers, UpdateType) -> case catch(couch_db:update_doc(Db, Doc, Options, UpdateType)) of {ok, _} -> ok; Error -> - ?LOG_INFO("Batch doc error (~s): ~p",[DocId, Error]) + couch_log:info("Batch doc error (~s): ~p",[DocId, Error]) end end), send_json(Req, 202, Headers, {[ http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_httpd_misc_handlers.erl ---------------------------------------------------------------------- diff --git a/src/couch_httpd_misc_handlers.erl b/src/couch_httpd_misc_handlers.erl index 8101cdf..06fed5e 100644 --- a/src/couch_httpd_misc_handlers.erl +++ b/src/couch_httpd_misc_handlers.erl @@ -212,8 +212,10 @@ handle_config_req(#httpd{method=Method, path_parts=[_, Section, Key]}=Req) FallbackWhitelist; {error, _} -> [{WhitelistSection, WhitelistKey}] = FallbackWhitelist, - ?LOG_ERROR("Only whitelisting ~s/~s due to error parsing: ~p", - [WhitelistSection, WhitelistKey, WhitelistValue]), + couch_log:error("Only whitelisting ~s/~s due to error" + " parsing: ~p", + [WhitelistSection, WhitelistKey, + WhitelistValue]), FallbackWhitelist end, http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_httpd_oauth.erl ---------------------------------------------------------------------- diff --git a/src/couch_httpd_oauth.erl b/src/couch_httpd_oauth.erl index 15733da..0215240 100644 --- a/src/couch_httpd_oauth.erl +++ b/src/couch_httpd_oauth.erl @@ -54,15 +54,17 @@ oauth_auth_callback(#httpd{mochi_req = MochiReq} = Req, CbParams) -> true -> set_user_ctx(Req, User); false -> - ?LOG_DEBUG("OAuth handler: signature verification failed for user `~p`~n" - "Received signature is `~p`~n" - "HTTP method is `~p`~n" - "URL is `~p`~n" - "Parameters are `~p`~n" - "Consumer is `~p`, token secret is `~p`~n" - "Expected signature was `~p`~n", - [User, Sig, Method, Url, Params, Consumer, TokenSecret, - oauth:sign(Method, Url, Params, Consumer, Token, TokenSecret)]), + couch_log:debug("OAuth handler: signature verification failed for" + " user `~p`~n" + "Received signature is `~p`~n" + "HTTP method is `~p`~n" + "URL is `~p`~n" + "Parameters are `~p`~n" + "Consumer is `~p`, token secret is `~p`~n" + "Expected signature was `~p`~n", + [User, Sig, Method, Url, Params, Consumer, TokenSecret, + oauth:sign(Method, Url, Params, Consumer, Token, + TokenSecret)]), Req end. @@ -73,7 +75,8 @@ set_user_ctx(_Req, undefined) -> set_user_ctx(Req, Name) -> case couch_auth_cache:get_user_creds(Name) of nil -> - ?LOG_DEBUG("OAuth handler: user `~p` credentials not found", [Name]), + couch_log:debug("OAuth handler: user `~p` credentials not found", + [Name]), Req; User -> Roles = couch_util:get_value(<<"roles">>, User, []), @@ -209,7 +212,7 @@ serve_oauth(#httpd{mochi_req=MochiReq}=Req, Fun, FailSilently) -> Params = proplists:delete("realm", HeaderParams) ++ mochiweb_util:parse_qs(QueryString), - ?LOG_DEBUG("OAuth Params: ~p", [Params]), + couch_log:debug("OAuth Params: ~p", [Params]), case couch_util:get_value("oauth_version", Params, "1.0") of "1.0" -> case couch_util:get_value("oauth_consumer_key", Params, undefined) of @@ -267,10 +270,11 @@ get_callback_params(ConsumerKey, Params, Url) -> token_secret = TokenSecret, username = User }, - ?LOG_DEBUG("Got OAuth credentials, for ConsumerKey `~p` and " - "Token `~p`, from the views, User: `~p`, " - "ConsumerSecret: `~p`, TokenSecret: `~p`", - [ConsumerKey, Token, User, ConsumerSecret, TokenSecret]), + couch_log:debug("Got OAuth credentials, for ConsumerKey `~p` and " + "Token `~p`, from the views, User: `~p`, " + "ConsumerSecret: `~p`, TokenSecret: `~p`", + [ConsumerKey, Token, User, ConsumerSecret, + TokenSecret]), {ok, CbParams} end end. http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_httpd_rewrite.erl ---------------------------------------------------------------------- diff --git a/src/couch_httpd_rewrite.erl b/src/couch_httpd_rewrite.erl index 40d8a7b..e2a2421 100644 --- a/src/couch_httpd_rewrite.erl +++ b/src/couch_httpd_rewrite.erl @@ -177,7 +177,7 @@ handle_rewrite_req(#httpd{ MochiReq:get(raw_path), MochiReq:get(headers)), - ?LOG_DEBUG("rewrite to ~p ~n", [RawPath1]), + couch_log:debug("rewrite to ~p ~n", [RawPath1]), % build a new mochiweb request MochiReq1 = mochiweb_request:new(MochiReq:get(socket), @@ -439,7 +439,8 @@ path_to_list([<<"..">>|R], Acc, DotDotCount) when DotDotCount == 2 -> "false" -> path_to_list(R, [<<"..">>|Acc], DotDotCount+1); _Else -> - ?LOG_INFO("insecure_rewrite_rule ~p blocked", [lists:reverse(Acc) ++ [<<"..">>] ++ R]), + couch_log:info("insecure_rewrite_rule ~p blocked", + [lists:reverse(Acc) ++ [<<"..">>] ++ R]), throw({insecure_rewrite_rule, "too many ../.. segments"}) end; path_to_list([<<"..">>|R], Acc, DotDotCount) -> http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_httpd_vhost.erl ---------------------------------------------------------------------- diff --git a/src/couch_httpd_vhost.erl b/src/couch_httpd_vhost.erl index 29fddfe..0f01294 100644 --- a/src/couch_httpd_vhost.erl +++ b/src/couch_httpd_vhost.erl @@ -134,7 +134,7 @@ redirect_to_vhost(MochiReq, VhostTarget) -> Path = MochiReq:get(raw_path), Target = append_path(VhostTarget, Path), - ?LOG_DEBUG("Vhost Target: '~p'~n", [Target]), + couch_log:debug("Vhost Target: '~p'~n", [Target]), Headers = mochiweb_headers:enter("x-couchdb-vhost-path", Path, MochiReq:get(headers)), http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_native_process.erl ---------------------------------------------------------------------- diff --git a/src/couch_native_process.erl b/src/couch_native_process.erl index b09716e..4cc862d 100644 --- a/src/couch_native_process.erl +++ b/src/couch_native_process.erl @@ -71,7 +71,7 @@ handle_call({set_timeout, TimeOut}, _From, State) -> {reply, ok, State#evstate{timeout=TimeOut}}; handle_call({prompt, Data}, _From, State) -> - ?LOG_DEBUG("Prompt native qs: ~s",[?JSON_ENCODE(Data)]), + couch_log:debug("Prompt native qs: ~s",[?JSON_ENCODE(Data)]), {NewState, Resp} = try run(State, to_binary(Data)) of {S, R} -> {S, R} catch @@ -171,7 +171,7 @@ run(#evstate{ddocs=DDocs}=State, [<<"ddoc">>, DDocId | Rest]) -> DDoc = load_ddoc(DDocs, DDocId), ddoc(State, DDoc, Rest); run(_, Unknown) -> - ?LOG_ERROR("Native Process: Unknown command: ~p~n", [Unknown]), + couch_log:error("Native Process: Unknown command: ~p~n", [Unknown]), throw({error, unknown_command}). ddoc(State, {DDoc}, [FunPath, Args]) -> @@ -195,7 +195,7 @@ ddoc(State, {_, Fun}, [<<"filters">>|_], [Docs, Req]) -> case catch Fun(Doc, Req) of true -> true; false -> false; - {'EXIT', Error} -> ?LOG_ERROR("~p", [Error]) + {'EXIT', Error} -> couch_log:error("~p", [Error]) end end, Resp = lists:map(FilterFunWrapper, Docs), @@ -264,7 +264,7 @@ bindings(State, Sig, DDoc) -> Self = self(), Log = fun(Msg) -> - ?LOG_INFO(Msg, []) + couch_log:info(Msg, []) end, Emit = fun(Id, Value) -> @@ -339,8 +339,8 @@ makefun(_State, Source, BindFuns) when is_list(BindFuns) -> {ok, [ParsedForm]} -> ParsedForm; {error, {LineNum, _Mod, [Mesg, Params]}}=Error -> - io:format(standard_error, "Syntax error on line: ~p~n", [LineNum]), - io:format(standard_error, "~s~p~n", [Mesg, Params]), + couch_log:error("Syntax error on line: ~p~n~s~p~n", + [LineNum, Mesg, Params]), throw(Error) end, Bindings = lists:foldl(fun({Name, Fun}, Acc) -> http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_os_daemons.erl ---------------------------------------------------------------------- diff --git a/src/couch_os_daemons.erl b/src/couch_os_daemons.erl index 7856678..606d147 100644 --- a/src/couch_os_daemons.erl +++ b/src/couch_os_daemons.erl @@ -65,7 +65,8 @@ handle_call({daemon_info, Options}, _From, Table) when is_list(Options) -> {reply, {ok, Table}, Table} end; handle_call(Msg, From, Table) -> - ?LOG_ERROR("Unknown call message to ~p from ~p: ~p", [?MODULE, From, Msg]), + couch_log:error("Unknown call message to ~p from ~p: ~p", + [?MODULE, From, Msg]), {stop, error, Table}. handle_cast({config_change, Sect, Key}, Table) -> @@ -78,7 +79,7 @@ handle_cast({config_change, Sect, Key}, Table) -> handle_cast(stop, Table) -> {stop, normal, Table}; handle_cast(Msg, Table) -> - ?LOG_ERROR("Unknown cast message to ~p: ~p", [?MODULE, Msg]), + couch_log:error("Unknown cast message to ~p: ~p", [?MODULE, Msg]), {stop, error, Table}. handle_info({gen_event_EXIT, {config_listener, ?MODULE}, _Reason}, State) -> @@ -90,20 +91,21 @@ handle_info(restart_config_listener, State) -> handle_info({'EXIT', Port, Reason}, Table) -> case ets:lookup(Table, Port) of [] -> - ?LOG_INFO("Port ~p exited after stopping: ~p~n", [Port, Reason]); + couch_log:info("Port ~p exited after stopping: ~p~n", + [Port, Reason]); [#daemon{status=stopping}] -> true = ets:delete(Table, Port); [#daemon{name=Name, status=restarting}=D] -> - ?LOG_INFO("Daemon ~p restarting after config change.", [Name]), + couch_log:info("Daemon ~p restarting after config change.", [Name]), true = ets:delete(Table, Port), {ok, Port2} = start_port(D#daemon.cmd), true = ets:insert(Table, D#daemon{ port=Port2, status=running, kill=undefined, buf=[] }); [#daemon{name=Name, status=halted}] -> - ?LOG_ERROR("Halted daemon process: ~p", [Name]); + couch_log:error("Halted daemon process: ~p", [Name]); [D] -> - ?LOG_ERROR("Invalid port state at exit: ~p", [D]) + couch_log:error("Invalid port state at exit: ~p", [D]) end, {noreply, Table}; handle_info({Port, closed}, Table) -> @@ -111,10 +113,10 @@ handle_info({Port, closed}, Table) -> handle_info({Port, {exit_status, Status}}, Table) -> case ets:lookup(Table, Port) of [] -> - ?LOG_ERROR("Unknown port ~p exiting ~p", [Port, Status]), + couch_log:error("Unknown port ~p exiting ~p", [Port, Status]), {stop, {error, unknown_port_died, Status}, Table}; [#daemon{name=Name, status=restarting}=D] -> - ?LOG_INFO("Daemon ~p restarting after config change.", [Name]), + couch_log:info("Daemon ~p restarting after config change.", [Name]), true = ets:delete(Table, Port), {ok, Port2} = start_port(D#daemon.cmd), true = ets:insert(Table, D#daemon{ @@ -124,7 +126,7 @@ handle_info({Port, {exit_status, Status}}, Table) -> [#daemon{status=stopping}=D] -> % The configuration changed and this daemon is no % longer needed. - ?LOG_DEBUG("Port ~p shut down.", [D#daemon.name]), + couch_log:debug("Port ~p shut down.", [D#daemon.name]), true = ets:delete(Table, Port), {noreply, Table}; [D] -> @@ -135,7 +137,7 @@ handle_info({Port, {exit_status, Status}}, Table) -> % Halting the process. We won't try and reboot % until the configuration changes. Fmt = "Daemon ~p halted with exit_status ~p", - ?LOG_ERROR(Fmt, [D#daemon.name, Status]), + couch_log:error(Fmt, [D#daemon.name, Status]), D2 = D#daemon{status=halted, errors=nil, buf=nil}, true = ets:insert(Table, D2), {noreply, Table}; @@ -143,7 +145,7 @@ handle_info({Port, {exit_status, Status}}, Table) -> % We're guessing it was a random error, this daemon % has behaved so we'll give it another chance. Fmt = "Daemon ~p is being rebooted after exit_status ~p", - ?LOG_INFO(Fmt, [D#daemon.name, Status]), + couch_log:info(Fmt, [D#daemon.name, Status]), true = ets:delete(Table, Port), {ok, Port2} = start_port(D#daemon.cmd), true = ets:insert(Table, D#daemon{ @@ -171,7 +173,8 @@ handle_info({Port, {data, {eol, Data}}}, Table) -> _Else -> D2 = case (catch ?JSON_DECODE(Line)) of {invalid_json, Rejected} -> - ?LOG_ERROR("Ignoring OS daemon request: ~p", [Rejected]), + couch_log:error("Ignoring OS daemon request: ~p", + [Rejected]), D; JSON -> {ok, D3} = handle_port_message(D, JSON), @@ -181,13 +184,13 @@ handle_info({Port, {data, {eol, Data}}}, Table) -> end, {noreply, Table}; handle_info({Port, Error}, Table) -> - ?LOG_ERROR("Unexpectd message from port ~p: ~p", [Port, Error]), + couch_log:error("Unexpectd message from port ~p: ~p", [Port, Error]), stop_port(Port), [D] = ets:lookup(Table, Port), true = ets:insert(Table, D#daemon{status=restarting, buf=nil}), {noreply, Table}; handle_info(Msg, Table) -> - ?LOG_ERROR("Unexpected info message to ~p: ~p", [?MODULE, Msg]), + couch_log:error("Unexpected info message to ~p: ~p", [?MODULE, Msg]), {stop, error, Table}. code_change(_OldVsn, State, _Extra) -> @@ -223,10 +226,11 @@ start_port(Command, EnvPairs) -> stop_port(#daemon{port=Port, kill=undefined}=D) -> - ?LOG_ERROR("Stopping daemon without a kill command: ~p", [D#daemon.name]), + couch_log:error("Stopping daemon without a kill command: ~p", + [D#daemon.name]), catch port_close(Port); stop_port(#daemon{port=Port}=D) -> - ?LOG_DEBUG("Stopping daemon: ~p", [D#daemon.name]), + couch_log:debug("Stopping daemon: ~p", [D#daemon.name]), os:cmd(D#daemon.kill), catch port_close(Port). @@ -261,21 +265,21 @@ handle_port_message(#daemon{name=Name}=Daemon, [<<"log">>, Msg, {Opts}]) -> handle_log_message(Name, Msg, Level), {ok, Daemon}; handle_port_message(#daemon{name=Name}=Daemon, Else) -> - ?LOG_ERROR("Daemon ~p made invalid request: ~p", [Name, Else]), + couch_log:error("Daemon ~p made invalid request: ~p", [Name, Else]), {ok, Daemon}. handle_log_message(Name, Msg, _Level) when not is_binary(Msg) -> - ?LOG_ERROR("Invalid log message from daemon ~p: ~p", [Name, Msg]); + couch_log:error("Invalid log message from daemon ~p: ~p", [Name, Msg]); handle_log_message(Name, Msg, <<"debug">>) -> - ?LOG_DEBUG("Daemon ~p :: ~s", [Name, ?b2l(Msg)]); + couch_log:debug("Daemon ~p :: ~s", [Name, ?b2l(Msg)]); handle_log_message(Name, Msg, <<"info">>) -> - ?LOG_INFO("Daemon ~p :: ~s", [Name, ?b2l(Msg)]); + couch_log:info("Daemon ~p :: ~s", [Name, ?b2l(Msg)]); handle_log_message(Name, Msg, <<"error">>) -> - ?LOG_ERROR("Daemon: ~p :: ~s", [Name, ?b2l(Msg)]); + couch_log:error("Daemon: ~p :: ~s", [Name, ?b2l(Msg)]); handle_log_message(Name, Msg, Level) -> - ?LOG_ERROR("Invalid log level from daemon: ~p", [Level]), - ?LOG_INFO("Daemon: ~p :: ~s", [Name, ?b2l(Msg)]). + couch_log:error("Invalid log level from daemon: ~p", [Level]), + couch_log:info("Daemon: ~p :: ~s", [Name, ?b2l(Msg)]). % % Daemon management helpers http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_os_process.erl ---------------------------------------------------------------------- diff --git a/src/couch_os_process.erl b/src/couch_os_process.erl index 8aaf5db..5b9a17f 100644 --- a/src/couch_os_process.erl +++ b/src/couch_os_process.erl @@ -55,7 +55,7 @@ prompt(Pid, Data) -> {ok, Result} -> Result; Error -> - ?LOG_ERROR("OS Process Error ~p :: ~p",[Pid,Error]), + couch_log:error("OS Process Error ~p :: ~p",[Pid,Error]), throw(Error) end. @@ -91,12 +91,13 @@ readline(#os_proc{port = Port} = OsProc, Acc) -> % Standard JSON functions writejson(OsProc, Data) when is_record(OsProc, os_proc) -> JsonData = ?JSON_ENCODE(Data), - ?LOG_DEBUG("OS Process ~p Input :: ~s", [OsProc#os_proc.port, JsonData]), + couch_log:debug("OS Process ~p Input :: ~s", + [OsProc#os_proc.port, JsonData]), true = writeline(OsProc, JsonData). readjson(OsProc) when is_record(OsProc, os_proc) -> Line = iolist_to_binary(readline(OsProc)), - ?LOG_DEBUG("OS Process ~p Output :: ~s", [OsProc#os_proc.port, Line]), + couch_log:debug("OS Process ~p Output :: ~s", [OsProc#os_proc.port, Line]), try % Don't actually parse the whole JSON. Just try to see if it's % a command or a doc map/reduce/filter/show/list/update output. @@ -110,12 +111,13 @@ readjson(OsProc) when is_record(OsProc, os_proc) -> case ?JSON_DECODE(Line) of [<<"log">>, Msg] when is_binary(Msg) -> % we got a message to log. Log it and continue - ?LOG_INFO("OS Process ~p Log :: ~s", [OsProc#os_proc.port, Msg]), + couch_log:info("OS Process ~p Log :: ~s", + [OsProc#os_proc.port, Msg]), readjson(OsProc); [<<"error">>, Id, Reason] -> throw({error, {couch_util:to_existing_atom(Id),Reason}}); [<<"fatal">>, Id, Reason] -> - ?LOG_INFO("OS Process ~p Fatal Error :: ~s ~p", + couch_log:info("OS Process ~p Fatal Error :: ~s ~p", [OsProc#os_proc.port, Id, Reason]), throw({couch_util:to_existing_atom(Id),Reason}); _Result -> @@ -156,7 +158,7 @@ init([Command, Options, PortOptions]) -> }, KillCmd = iolist_to_binary(readline(BaseProc)), Pid = self(), - ?LOG_DEBUG("OS Process Start :: ~p", [BaseProc#os_proc.port]), + couch_log:debug("OS Process Start :: ~p", [BaseProc#os_proc.port]), spawn(fun() -> % this ensure the real os process is killed when this process dies. erlang:monitor(process, Pid), @@ -204,7 +206,7 @@ handle_cast({send, Data}, #os_proc{writer=Writer, idle=Idle}=OsProc) -> {noreply, OsProc, Idle} catch throw:OsError -> - ?LOG_ERROR("Failed sending data: ~p -> ~p", [Data, OsError]), + couch_log:error("Failed sending data: ~p -> ~p", [Data, OsError]), {stop, normal, OsProc} end; handle_cast(garbage_collect, #os_proc{idle=Idle}=OsProc) -> @@ -213,7 +215,7 @@ handle_cast(garbage_collect, #os_proc{idle=Idle}=OsProc) -> handle_cast(stop, OsProc) -> {stop, normal, OsProc}; handle_cast(Msg, #os_proc{idle=Idle}=OsProc) -> - ?LOG_DEBUG("OS Proc: Unknown cast: ~p", [Msg]), + couch_log:debug("OS Proc: Unknown cast: ~p", [Msg]), {noreply, OsProc, Idle}. handle_info(timeout, #os_proc{idle=Idle}=OsProc) -> @@ -221,13 +223,13 @@ handle_info(timeout, #os_proc{idle=Idle}=OsProc) -> erlang:garbage_collect(), {noreply, OsProc, Idle}; handle_info({Port, {exit_status, 0}}, #os_proc{port=Port}=OsProc) -> - ?LOG_INFO("OS Process terminated normally", []), + couch_log:info("OS Process terminated normally", []), {stop, normal, OsProc}; handle_info({Port, {exit_status, Status}}, #os_proc{port=Port}=OsProc) -> - ?LOG_ERROR("OS Process died with status: ~p", [Status]), + couch_log:error("OS Process died with status: ~p", [Status]), {stop, {exit_status, Status}, OsProc}; handle_info(Msg, #os_proc{idle=Idle}=OsProc) -> - ?LOG_DEBUG("OS Proc: Unknown info: ~p", [Msg]), + couch_log:debug("OS Proc: Unknown info: ~p", [Msg]), {noreply, OsProc, Idle}. code_change(_, {os_proc, Cmd, Port, W, R, Timeout} , _) -> http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_proc_manager.erl ---------------------------------------------------------------------- diff --git a/src/couch_proc_manager.erl b/src/couch_proc_manager.erl index 7ca8e01..5bb154e 100644 --- a/src/couch_proc_manager.erl +++ b/src/couch_proc_manager.erl @@ -204,7 +204,7 @@ handle_cast({os_proc_idle, Pid}, #state{counts=Counts}=State) -> [#proc_int{client=undefined, lang=Lang}=Proc] -> case dict:find(Lang, Counts) of {ok, Count} when Count >= State#state.soft_limit -> - ?LOG_INFO("Closing idle OS Process: ~p", [Pid]), + couch_log:info("Closing idle OS Process: ~p", [Pid]), remove_proc(State, Proc); {ok, _} -> State @@ -245,7 +245,7 @@ handle_info({'EXIT', Pid, spawn_error}, State) -> {noreply, flush_waiters(NewState, Lang)}; handle_info({'EXIT', Pid, Reason}, State) -> - ?LOG_INFO("~p ~p died ~p", [?MODULE, Pid, Reason]), + couch_log:info("~p ~p died ~p", [?MODULE, Pid, Reason]), case ets:lookup(?PROCS, Pid) of [#proc_int{} = Proc] -> NewState = remove_proc(State, Proc), @@ -294,7 +294,7 @@ find_proc(State, Client, [Fun | FindFuns]) -> {ok, Proc} -> {reply, {ok, Proc, State#state.config}, State} catch error:Reason -> - ?LOG_ERROR("~p ~p ~p", [?MODULE, Reason, erlang:get_stacktrace()]), + couch_log:error("~p ~p ~p", [?MODULE, Reason, erlang:get_stacktrace()]), {reply, {error, Reason}, State} end; find_proc(State, Client, []) -> http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_server.erl ---------------------------------------------------------------------- diff --git a/src/couch_server.erl b/src/couch_server.erl index 66a3c74..8f9696b 100644 --- a/src/couch_server.erl +++ b/src/couch_server.erl @@ -211,8 +211,9 @@ init([]) -> start_time=couch_util:rfc1123_date()}}. terminate(Reason, Srv) -> - ?LOG_ERROR("couch_server terminating with ~p, state ~2048p", [Reason, - Srv#server{dbname_regexp = redacted, lru = redacted}]), + couch_log:error("couch_server terminating with ~p, state ~2048p", + [Reason, + Srv#server{dbname_regexp = redacted, lru = redacted}]), ets:foldl(fun(#db{main_pid=Pid}, _) -> couch_util:shutdown_sync(Pid) end, nil, couch_dbs), ok. @@ -374,7 +375,7 @@ handle_call({open_result, DbName, Error}, {FromPid, _Tag}, Server) -> % icky hack of field values - compactor_pid used to store clients [#db{fd=ReqType, compactor_pid=Froms}=Db] = ets:lookup(couch_dbs, DbName), [gen_server:reply(From, Error) || From <- Froms], - ?LOG_INFO("open_result error ~p for ~s", [Error, DbName]), + couch_log:info("open_result error ~p for ~s", [Error, DbName]), true = ets:delete(couch_dbs, DbName), true = ets:delete(couch_dbs_pid_to_name, FromPid), NewServer = case ReqType of @@ -405,7 +406,7 @@ handle_call({open, DbName, Options}, From, Server) -> true = ets:insert(couch_dbs, Db#db{compactor_pid = [From|Froms]}), if length(Froms) =< 10 -> ok; true -> Fmt = "~b clients waiting to open db ~s", - ?LOG_INFO(Fmt, [length(Froms), DbName]) + couch_log:info(Fmt, [length(Froms), DbName]) end, {noreply, Server}; [#db{} = Db] -> @@ -520,9 +521,9 @@ handle_info({'EXIT', Pid, Reason}, Server) -> if Reason /= snappy_nif_not_loaded -> ok; true -> Msg = io_lib:format("To open the database `~s`, Apache CouchDB " "must be built with Erlang OTP R13B04 or higher.", [DbName]), - ?LOG_ERROR(Msg, []) + couch_log:error(Msg, []) end, - ?LOG_INFO("db ~s died with reason ~p", [DbName, Reason]), + couch_log:info("db ~s died with reason ~p", [DbName, Reason]), % icky hack of field values - compactor_pid used to store clients if is_list(Froms) -> [gen_server:reply(From, Reason) || From <- Froms]; http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_sup.erl ---------------------------------------------------------------------- diff --git a/src/couch_sup.erl b/src/couch_sup.erl index 80cef4b..467a1f5 100644 --- a/src/couch_sup.erl +++ b/src/couch_sup.erl @@ -92,7 +92,7 @@ notify_error(Error) -> notify_uris() -> lists:foreach(fun(Uri) -> - ?LOG_INFO("Apache CouchDB has started on ~s", [Uri]) + couch_log:info("Apache CouchDB has started on ~s", [Uri]) end, get_uris()). http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/d28af185/src/couch_task_status.erl ---------------------------------------------------------------------- diff --git a/src/couch_task_status.erl b/src/couch_task_status.erl index 849ebd7..4083c3f 100644 --- a/src/couch_task_status.erl +++ b/src/couch_task_status.erl @@ -134,7 +134,7 @@ handle_call(all, _, Server) -> handle_cast({update_status, Pid, NewProps}, Server) -> case ets:lookup(?MODULE, Pid) of [{Pid, _CurProps}] -> - ?LOG_DEBUG("New task status for ~p: ~p", [Pid, NewProps]), + couch_log:debug("New task status for ~p: ~p", [Pid, NewProps]), true = ets:insert(?MODULE, {Pid, NewProps}); _ -> % Task finished/died in the meanwhile and we must have received