Class: RSpec::Buildkite::Analytics::Session::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/buildkite/analytics/session.rb

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger.



16
17
18
# File 'lib/rspec/buildkite/analytics/session.rb', line 16

def initialize
  @log = Queue.new
end

Instance Method Details

#to_arrayObject



24
25
26
27
28
29
30
31
32
# File 'lib/rspec/buildkite/analytics/session.rb', line 24

def to_array
  # This empty check is important cos calling pop on a Queue is blocking until
  # it's not empty
  if @log.empty?
    []
  else
    Array.new(@log.size) { @log.pop }
  end
end

#write(str) ⇒ Object



20
21
22
# File 'lib/rspec/buildkite/analytics/session.rb', line 20

def write(str)
  @log << "#{Time.now.strftime("%F-%R:%S.%9N")} #{Thread.current} #{str}"
end