diff options
author | Jan Lehnardt <jan@apache.org> | 2009-05-12 19:36:15 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2009-05-12 19:36:15 +0000 |
commit | 7c76d131110e4641114e3066844e7195efb2f33b (patch) | |
tree | fc7e7f4af83b58adeb2b3eba11ad3876fc2a788d /src/couchdb/couch_httpd_misc_handlers.erl | |
parent | b37ce2b377cff6c3e358adf4963ae6290942fae7 (diff) |
Add non-streaming log-file handler. A GET request to /_log will show the last 1000 bytes of the logflie. More bytes can be requested with GET /_log?bytes=10000.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@774045 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_misc_handlers.erl')
-rw-r--r-- | src/couchdb/couch_httpd_misc_handlers.erl | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl index d03cbd3f..92e0252a 100644 --- a/src/couchdb/couch_httpd_misc_handlers.erl +++ b/src/couchdb/couch_httpd_misc_handlers.erl @@ -14,7 +14,7 @@ -export([handle_welcome_req/2,handle_favicon_req/2,handle_utils_dir_req/2, handle_all_dbs_req/1,handle_replicate_req/1,handle_restart_req/1, - handle_uuids_req/1,handle_config_req/1, + handle_uuids_req/1,handle_config_req/1,handle_log_req/1, handle_task_status_req/1]). -export([increment_update_seq_req/2]). @@ -195,3 +195,15 @@ increment_update_seq_req(#httpd{method='POST'}=Req, Db) -> increment_update_seq_req(Req, _Db) -> send_method_not_allowed(Req, "POST"). +% httpd log handlers + +handle_log_req(#httpd{method='GET'}=Req) -> + LastBytes = list_to_integer(couch_httpd:qs_value(Req, "bytes", "1000")), + {ok, Resp} = start_chunked_response(Req, 200, [ + % send a plaintext response + {"Content-Type", "text/plain; charset=utf-8"} + ]), + send_chunk(Resp, couch_log:read(LastBytes)), + send_chunk(Resp, ""); +handle_log_req(Req) -> + send_method_not_allowed(Req, "GET"). |