diff options
author | Robert Newson <robert.newson@cloudant.com> | 2011-09-28 11:18:06 +0100 |
---|---|---|
committer | Robert Newson <robert.newson@cloudant.com> | 2011-09-28 11:32:50 +0100 |
commit | 954ddf0fca558f17f39e68df8311ee9057beb390 (patch) | |
tree | 2542c112210363076be1a8bc7b24e13bfaf1c055 /apps/couch/src/couch_log.erl | |
parent | c8d7b6d8c3cb881d525be80bc6b16bc08822df65 (diff) | |
parent | befbdfb11f45bd2a5ccffb6b0d5ac04435ac9e55 (diff) |
Merge 1.1.x changes
Conflicts:
apps/couch/include/couch_db.hrl
apps/couch/src/couch_db.erl
apps/couch/src/couch_os_process.erl
apps/couch/src/couch_query_servers.erl
apps/couch/src/couch_rep.erl
apps/couch/src/couch_replication_manager.erl
apps/couch/src/couch_view_compactor.erl
apps/couch/src/couch_view_group.erl
apps/couch/src/couch_view_updater.erl
configure.ac
couchjs/c_src/http.c
couchjs/c_src/main.c
couchjs/c_src/utf8.c
etc/windows/couchdb.iss.tpl
src/couchdb/priv/Makefile.am
src/couchdb/priv/couch_js/main.c
test/etap/160-vhosts.t
test/etap/200-view-group-no-db-leaks.t
test/etap/Makefile.am
BugzID: 12645
Diffstat (limited to 'apps/couch/src/couch_log.erl')
-rw-r--r-- | apps/couch/src/couch_log.erl | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/apps/couch/src/couch_log.erl b/apps/couch/src/couch_log.erl index 9bac7450..362d092d 100644 --- a/apps/couch/src/couch_log.erl +++ b/apps/couch/src/couch_log.erl @@ -25,22 +25,12 @@ -define(LEVEL_TMI, 0). debug(Format, Args) -> - case debug_on() of - false -> - ok; - true -> - {ConsoleMsg, FileMsg} = get_log_messages(self(), debug, Format, Args), - gen_event:sync_notify(error_logger, {couch_debug, ConsoleMsg, FileMsg}) - end. + {ConsoleMsg, FileMsg} = get_log_messages(self(), debug, Format, Args), + gen_event:sync_notify(error_logger, {couch_debug, ConsoleMsg, FileMsg}). info(Format, Args) -> - case info_on() of - false -> - ok; - true -> - {ConsoleMsg, FileMsg} = get_log_messages(self(), info, Format, Args), - gen_event:sync_notify(error_logger, {couch_info, ConsoleMsg, FileMsg}) - end. + {ConsoleMsg, FileMsg} = get_log_messages(self(), info, Format, Args), + gen_event:sync_notify(error_logger, {couch_info, ConsoleMsg, FileMsg}). error(Format, Args) -> {ConsoleMsg, FileMsg} = get_log_messages(self(), error, Format, Args), @@ -180,6 +170,15 @@ get_log_messages(Pid, Level, Format, Args) -> read(Bytes, Offset) -> LogFileName = couch_config:get("log", "file"), LogFileSize = filelib:file_size(LogFileName), + MaxChunkSize = list_to_integer( + couch_config:get("httpd", "log_max_chunk_size", "1000000")), + case Bytes > MaxChunkSize of + true -> + throw({bad_request, "'bytes' cannot exceed " ++ + integer_to_list(MaxChunkSize)}); + false -> + ok + end, {ok, Fd} = file:open(LogFileName, [read]), Start = lists:max([LogFileSize - Bytes, 0]) + Offset, @@ -188,4 +187,5 @@ read(Bytes, Offset) -> % TODO: make streaming {ok, Chunk} = file:pread(Fd, Start, LogFileSize), + ok = file:close(Fd), Chunk. |