Class: Aspera::LineLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/aspera/line_logger.rb

Overview

used for logging http

Instance Method Summary collapse

Constructor Details

#initialize(level) ⇒ LineLogger

Returns a new instance of LineLogger.



8
9
10
11
# File 'lib/aspera/line_logger.rb', line 8

def initialize(level)
  @level = level
  @buffer = []
end

Instance Method Details

#<<(string) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/aspera/line_logger.rb', line 13

def <<(string)
  return if string.nil? || string.empty?
  if !string.end_with?("\n")
    @buffer.push(string)
    return
  end
  Log.log.send(@level, @buffer.join('') + string.chomp)
  @buffer.clear
end