Class: Capybara::Lightpanda::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/lightpanda/logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output = nil) ⇒ Logger

Returns a new instance of Logger.



8
9
10
11
12
# File 'lib/capybara/lightpanda/logger.rb', line 8

def initialize(output = nil)
  @output = output
  @suppressed = false
  @started_at = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



6
7
8
# File 'lib/capybara/lightpanda/logger.rb', line 6

def output
  @output
end

Instance Method Details

#elapsed_timeObject



32
33
34
# File 'lib/capybara/lightpanda/logger.rb', line 32

def elapsed_time
  format("%.3fs", ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - @started_at)
end

#puts(message) ⇒ Object



14
15
16
17
18
# File 'lib/capybara/lightpanda/logger.rb', line 14

def puts(message)
  return if @suppressed || @output.nil?

  @output.puts(message)
end

#suppressObject



20
21
22
23
24
25
26
# File 'lib/capybara/lightpanda/logger.rb', line 20

def suppress
  prev = @suppressed
  @suppressed = true
  yield
ensure
  @suppressed = prev
end

#suppressed?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/capybara/lightpanda/logger.rb', line 28

def suppressed?
  @suppressed
end