summaryrefslogtreecommitdiff
path: root/apps/couch/src/couch_log.erl
diff options
context:
space:
mode:
authorAdam Kocoloski <adam@cloudant.com>2011-10-04 13:11:12 -0700
committerAdam Kocoloski <adam@cloudant.com>2011-10-04 13:11:12 -0700
commitda7284ed2844926c7df0efef12ba30d8e2e6d039 (patch)
tree10fa2d5cf35bfae4d48fc632924cec98ee02a22a /apps/couch/src/couch_log.erl
parentb57aadd742e4f8cc925ba4f005ae658c43a7c5b4 (diff)
parent4e19639a64d3033e1cc7c22a0b7404d277643c78 (diff)
Merge pull request #67 from cloudant/12645-merge_latest_1.1.x
Diffstat (limited to 'apps/couch/src/couch_log.erl')
-rw-r--r--apps/couch/src/couch_log.erl28
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.