summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2009-11-02 20:31:08 +0000
committerAdam Kocoloski <kocolosk@apache.org>2009-11-02 20:31:08 +0000
commit9bd34f364e1d9d3a02391cc3ace1ee98d84ae547 (patch)
tree4e602a9916b851bf9bfb557c095c0af936a22512
parent8c994a5eda96cabef85817ec4294276bcbd3a9bb (diff)
cast string status codes (from _externals) to integers before logging. COUCHDB-551
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@832091 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/couchdb/couch_httpd.erl2
-rw-r--r--src/couchdb/couch_util.erl9
2 files changed, 9 insertions, 2 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 9ad39e2d..7b876cfa 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -375,7 +375,7 @@ log_request(#httpd{mochi_req=MochiReq,peer=Peer,method=Method}, Code) ->
Peer,
Method,
MochiReq:get(raw_path),
- Code
+ couch_util:to_integer(Code)
]).
diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl
index 7efc07c0..cdae0d4a 100644
--- a/src/couchdb/couch_util.erl
+++ b/src/couchdb/couch_util.erl
@@ -19,7 +19,7 @@
-export([encodeBase64/1, decodeBase64/1, encodeBase64Url/1, decodeBase64Url/1,
to_hex/1,parse_term/1, dict_find/3]).
-export([file_read_size/1, get_nested_json_value/2, json_user_ctx/1]).
--export([to_binary/1, to_list/1, url_encode/1]).
+-export([to_binary/1, to_integer/1, to_list/1, url_encode/1]).
-include("couch_db.hrl").
-include_lib("kernel/include/file.hrl").
@@ -371,6 +371,13 @@ to_binary(V) when is_atom(V) ->
to_binary(V) ->
list_to_binary(io_lib:format("~p", [V])).
+to_integer(V) when is_integer(V) ->
+ V;
+to_integer(V) when is_list(V) ->
+ erlang:list_to_integer(V);
+to_integer(V) when is_binary(V) ->
+ erlang:list_to_integer(binary_to_list(V)).
+
to_list(V) when is_list(V) ->
V;
to_list(V) when is_binary(V) ->