Class: Selenium::WebDriver::Logger

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/selenium/webdriver/common/logger.rb

Overview

Examples:

Enable full logging

Selenium::WebDriver.logger.level = :debug

Log to file

Selenium::WebDriver.logger.output = 'selenium.log'

Use logger manually

Selenium::WebDriver.logger.info('This is info message')
Selenium::WebDriver.logger.warn('This is warning message')

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger.



48
49
50
# File 'lib/selenium/webdriver/common/logger.rb', line 48

def initialize
  @logger = create_logger($stdout)
end

Instance Method Details

#deprecate(old, new = nil) ⇒ Object

Marks code as deprecated with/without replacement.

Parameters:

  • old (String)
  • new (String, nil) (defaults to: nil)


82
83
84
85
86
87
88
89
90
91
# File 'lib/selenium/webdriver/common/logger.rb', line 82

def deprecate(old, new = nil)
  message = +"[DEPRECATION] #{old} is deprecated"
  message << if new
               ". Use #{new} instead."
             else
               ' and will be removed in the next releases.'
             end

  warn message
end

#ioObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns IO object used by logger internally.

Normally, we would have never needed it, but we want to use it as IO object for all child processes to ensure their output is redirected there.

It is only used in debug level, in other cases output is suppressed.



72
73
74
# File 'lib/selenium/webdriver/common/logger.rb', line 72

def io
  @logger.instance_variable_get(:@logdev).dev
end

#output=(io) ⇒ Object

Changes logger output to a new IO.

Parameters:

  • io (String)


57
58
59
# File 'lib/selenium/webdriver/common/logger.rb', line 57

def output=(io)
  @logger.reopen(io)
end