Class: Selenium::WebDriver::Logger
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Logger
- Extended by:
- Forwardable
- Includes:
- Logger::Severity
- Defined in:
- lib/selenium/webdriver/common/logger.rb
Overview
Instance Method Summary collapse
-
#deprecate(old, new) ⇒ Object
Marks code as deprecated with replacement.
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
-
#io ⇒ Object
private
Returns IO object used by logger internally.
-
#level=(severity) ⇒ Object
For Ruby < 2.3 compatibility Based on github.com/ruby/ruby/blob/ruby_2_3/lib/logger.rb#L250.
- #output=(io) ⇒ Object
Constructor Details
#initialize ⇒ Logger
Returns a new instance of Logger.
47 48 49 |
# File 'lib/selenium/webdriver/common/logger.rb', line 47 def initialize @logger = create_logger($stdout) end |
Instance Method Details
#deprecate(old, new) ⇒ Object
Marks code as deprecated with replacement.
113 114 115 |
# File 'lib/selenium/webdriver/common/logger.rb', line 113 def deprecate(old, new) warn "[DEPRECATION] #{old} is deprecated. Use #{new} instead." end |
#io ⇒ Object
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.
99 100 101 102 103 104 105 |
# File 'lib/selenium/webdriver/common/logger.rb', line 99 def io if debug? @logger.instance_variable_get(:@logdev).instance_variable_get(:@dev) else File.new(Platform.null_device, 'w') end end |
#level=(severity) ⇒ Object
For Ruby < 2.3 compatibility Based on github.com/ruby/ruby/blob/ruby_2_3/lib/logger.rb#L250
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/selenium/webdriver/common/logger.rb', line 65 def level=(severity) if severity.is_a?(Integer) @logger.level = severity else case severity.to_s.downcase when 'debug'.freeze @logger.level = DEBUG when 'info'.freeze @logger.level = INFO when 'warn'.freeze @logger.level = WARN when 'error'.freeze @logger.level = ERROR when 'fatal'.freeze @logger.level = FATAL when 'unknown'.freeze @logger.level = UNKNOWN else raise ArgumentError, "invalid log level: #{severity}" end end end |
#output=(io) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/selenium/webdriver/common/logger.rb', line 51 def output=(io) # `Logger#reopen` was added in Ruby 2.3 if @logger.respond_to?(:reopen) @logger.reopen(io) else @logger = create_logger(io) end end |