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 = nil) ⇒ Object
Marks code as deprecated with/without 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.
45 46 47 |
# File 'lib/selenium/webdriver/common/logger.rb', line 45 def initialize @logger = create_logger($stdout) end |
Instance Method Details
#deprecate(old, new = nil) ⇒ Object
Marks code as deprecated with/without replacement.
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/selenium/webdriver/common/logger.rb', line 107 def deprecate(old, new = nil) = "[DEPRECATION] #{old} is deprecated" << if new ". Use #{new} instead." else ' and will be removed in the next releases.' end warn 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.
97 98 99 |
# File 'lib/selenium/webdriver/common/logger.rb', line 97 def io @logger.instance_variable_get(:@logdev).instance_variable_get(:@dev) end |
#level=(severity) ⇒ Object
For Ruby < 2.3 compatibility Based on github.com/ruby/ruby/blob/ruby_2_3/lib/logger.rb#L250
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/selenium/webdriver/common/logger.rb', line 63 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
49 50 51 52 53 54 55 56 |
# File 'lib/selenium/webdriver/common/logger.rb', line 49 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 |