couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r774095 - in /couchdb/trunk/src/couchdb: couch_httpd_misc_handlers.erl couch_log.erl
Date Tue, 12 May 2009 21:18:41 GMT
Author: jan
Date: Tue May 12 21:18:40 2009
New Revision: 774095

URL: http://svn.apache.org/viewvc?rev=774095&view=rev
Log:
add offset parameter so clients like Futon can deliver a consistent user experience

Modified:
    couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl
    couchdb/trunk/src/couchdb/couch_log.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl?rev=774095&r1=774094&r2=774095&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl Tue May 12 21:18:40 2009
@@ -198,12 +198,15 @@
 % httpd log handlers
 
 handle_log_req(#httpd{method='GET'}=Req) ->
-    LastBytes = list_to_integer(couch_httpd:qs_value(Req, "bytes", "1000")),
+    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),
     {ok, Resp} = start_chunked_response(Req, 200, [
         % send a plaintext response
-        {"Content-Type", "text/plain; charset=utf-8"}
+        {"Content-Type", "text/plain; charset=utf-8"},
+        {"Content-Length", integer_to_list(length(Chunk))}
     ]),
-    send_chunk(Resp, couch_log:read(LastBytes)),
+    send_chunk(Resp, Chunk),
     send_chunk(Resp, "");
 handle_log_req(Req) ->
     send_method_not_allowed(Req, "GET").

Modified: couchdb/trunk/src/couchdb/couch_log.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_log.erl?rev=774095&r1=774094&r2=774095&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_log.erl (original)
+++ couchdb/trunk/src/couchdb/couch_log.erl Tue May 12 21:18:40 2009
@@ -16,7 +16,7 @@
 -export([start_link/0,stop/0]).
 -export([debug_on/0,info_on/0,get_level/0,get_level_integer/0, set_level/1]).
 -export([init/1, handle_event/2, terminate/2, code_change/3, handle_info/2, handle_call/2]).
--export([read/1]).
+-export([read/2]).
 
 -define(LEVEL_ERROR, 3).
 -define(LEVEL_INFO, 2).
@@ -122,12 +122,12 @@
     {ok, Msg2, _} = regexp:gsub(lists:flatten(Msg),"\\r\\n|\\r|\\n", "\r\n"),
     ok = io:format(Fd, "[~s] [~s] [~p] ~s\r~n\r~n", [httpd_util:rfc1123_date(), Level, Pid,
Msg2]).
 
-read(LastBytes) ->
+read(Bytes, Offset) ->
     LogFileName = couch_config:get("log", "file"),
     LogFileSize = couch_util:file_read_size(LogFileName),
 
-    {ok, Fd} = file:open(LogFileName, [binary]),
-    Start = lists:max([LogFileSize - LastBytes, 0]),
+    {ok, Fd} = file:open(LogFileName, [read]),
+    Start = lists:max([LogFileSize - Bytes, 0]) + Offset,
 
     % TODO: truncate chopped first line
     % TODO: make streaming



Mime
View raw message