couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [5/8] git commit: Support for reading the query server log file
Date Mon, 11 Feb 2013 05:43:17 GMT
Support for reading the query server log file


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f012f23f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f012f23f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f012f23f

Branch: refs/heads/1677-feature-query_server_log_file
Commit: f012f23fe456f8b3ecc7f4746da2d7bc230125d4
Parents: a5bc557
Author: Jason Smith (work) <jhs@iriscouch.com>
Authored: Mon Feb 11 05:26:23 2013 +0000
Committer: Jason Smith (work) <jhs@iriscouch.com>
Committed: Mon Feb 11 05:29:25 2013 +0000

----------------------------------------------------------------------
 src/couchdb/couch_httpd_misc_handlers.erl |    9 +++++++--
 src/couchdb/couch_log.erl                 |   15 ++++++++++++++-
 2 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/f012f23f/src/couchdb/couch_httpd_misc_handlers.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl
index d1f947d..d242cee 100644
--- a/src/couchdb/couch_httpd_misc_handlers.erl
+++ b/src/couchdb/couch_httpd_misc_handlers.erl
@@ -257,11 +257,16 @@ increment_update_seq_req(Req, _Db) ->
 
 % httpd log handlers
 
-handle_log_req(#httpd{method='GET'}=Req) ->
+handle_log_req(#httpd{method='GET', path_parts=Path}=Req) ->
     ok = couch_httpd:verify_is_server_admin(Req),
     Bytes = list_to_integer(couch_httpd:qs_value(Req, "bytes", "1000")),
     Offset = list_to_integer(couch_httpd:qs_value(Req, "offset", "0")),
-    Chunk = couch_log:read(Bytes, Offset),
+    Chunk = case Path of
+        [_Log, <<"query_server">>] ->
+            couch_log:read_query_server(Bytes, Offset);
+        _ ->
+            couch_log:read(Bytes, Offset)
+    end,
     {ok, Resp} = start_chunked_response(Req, 200, [
         % send a plaintext response
         {"Content-Type", "text/plain; charset=utf-8"},

http://git-wip-us.apache.org/repos/asf/couchdb/blob/f012f23f/src/couchdb/couch_log.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl
index c30b67a..0dd1dfc 100644
--- a/src/couchdb/couch_log.erl
+++ b/src/couchdb/couch_log.erl
@@ -18,7 +18,7 @@
 -export([debug/2, info/2, warn/2, error/2, query_server/2]).
 -export([debug_on/0, info_on/0, warn_on/0, get_level/0, get_level_integer/0, set_level/1]).
 -export([debug_on/1, info_on/1, warn_on/1, get_level/1, get_level_integer/1, set_level/2]).
--export([read/2]).
+-export([read/2, read_query_server/2]).
 
 % gen_event callbacks
 -export([init/1, handle_event/2, terminate/2, code_change/3]).
@@ -289,6 +289,19 @@ get_abs_query_server_file() ->
 
 read(Bytes, Offset) ->
     LogFileName = couch_config:get("log", "file"),
+    read(LogFileName, Bytes, Offset).
+
+read_query_server(Bytes, Offset) ->
+    LogFileName = couch_config:get("log", "file"),
+    QuerySrvFile = get_abs_query_server_file(),
+    case QuerySrvFile of
+    LogFileName ->
+        ""; % No special query server file.
+    _ ->
+        read(QuerySrvFile, Bytes, Offset)
+    end.
+
+read(LogFileName, Bytes, Offset) ->
     case filelib:file_size(LogFileName)
     of 0 ->
         "";


Mime
View raw message