Class: Bricolage::StreamingLoad::LoadTaskLogger
- Inherits:
-
Object
- Object
- Bricolage::StreamingLoad::LoadTaskLogger
- Defined in:
- lib/bricolage/streamingload/loadtasklogger.rb
Instance Method Summary collapse
- #content(task) ⇒ Object
-
#initialize(s3ds) ⇒ LoadTaskLogger
constructor
A new instance of LoadTaskLogger.
- #key(task) ⇒ Object
- #log(task) ⇒ Object
Constructor Details
#initialize(s3ds) ⇒ LoadTaskLogger
Returns a new instance of LoadTaskLogger.
9 10 11 12 |
# File 'lib/bricolage/streamingload/loadtasklogger.rb', line 9 def initialize(s3ds) @s3ds = s3ds @logger = @s3ds.logger end |
Instance Method Details
#content(task) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/bricolage/streamingload/loadtasklogger.rb', line 26 def content(task) buf = StringIO.new task.chunks.each do |chunk| buf.puts %Q("#{task.id}","#{chunk.id}","#{chunk.url}") end buf.string end |
#key(task) ⇒ Object
21 22 23 24 |
# File 'lib/bricolage/streamingload/loadtasklogger.rb', line 21 def key(task) now = Time.now "task/#{now.strftime('%Y/%m/%d')}/task-#{task.id}.csv" end |
#log(task) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/bricolage/streamingload/loadtasklogger.rb', line 14 def log(task) csv = content(task) key = key(task) @logger.info "s3: put: #{@s3ds.url(key)}" @s3ds.object(key).put(body: csv) end |