lib/logjam_agent/request.rb in logjam_agent-0.26.4 vs lib/logjam_agent/request.rb in logjam_agent-0.26.5

- old
+ new

@@ -35,10 +35,11 @@ @mutex = Mutex.new @ignored = false @bytes_all_lines = 0 @max_bytes_all_lines = LogjamAgent.max_bytes_all_lines @max_line_length = LogjamAgent.max_line_length + @lines_dropped = false end def start_time=(start_time) @start_time = start_time @fields[:started_at] = start_time.iso8601 @@ -68,20 +69,25 @@ def caller_action @fields[:caller_action] end def add_line(severity, timestamp, message) - return if @bytes_all_lines > @max_bytes_all_lines - message = message.strip - if message.size > @max_line_length && severity < Logger::ERROR - message[(@max_line_length-21)..-1] = " ... [LINE TRUNCATED]" - end @mutex.synchronize do - if (@bytes_all_lines += message.bytesize) < @max_bytes_all_lines - @lines << [severity, format_time(timestamp), message] - else - @lines << [severity, format_time(timestamp), "... [LINES DROPPED]"] + if @bytes_all_lines > @max_bytes_all_lines + unless @lines_dropped + @lines << [severity, format_time(timestamp), "... [LINES DROPPED]"] + @lines_dropped = true + end + return end + message = message.strip + if message.size > @max_line_length && severity < Logger::ERROR + message[(@max_line_length-21)..-1] = " ... [LINE TRUNCATED]" + end + if (@bytes_all_lines += message.bytesize) > @max_bytes_all_lines + message[(@max_line_length-21)..-1] = " ... [LINE TRUNCATED]" + end + @lines << [severity, format_time(timestamp), message] end end def add_exception(exception, severity = Logger::ERROR) @mutex.synchronize do