Class: Selenium::WebDriver::Logger
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Logger
- Extended by:
- Forwardable
- Defined in:
- build/rb/lib/selenium/webdriver/common/logger.rb
Overview
Instance Method Summary collapse
-
#deprecate(old, new = nil, id: []) { ... } ⇒ Object
Marks code as deprecated with/without replacement.
-
#ignore(id) ⇒ Object
Will not log the provided ID.
-
#initialize(progname = 'Selenium') ⇒ Logger
constructor
A new instance of Logger.
-
#io ⇒ Object
private
Returns IO object used by logger internally.
-
#output=(io) ⇒ Object
Changes logger output to a new IO.
-
#warn(message, id: []) { ... } ⇒ Object
Overrides default #warn to skip ignored messages by provided id.
Constructor Details
#initialize(progname = 'Selenium') ⇒ Logger
Returns a new instance of Logger.
51 52 53 54 |
# File 'build/rb/lib/selenium/webdriver/common/logger.rb', line 51 def initialize(progname = 'Selenium') @logger = create_logger(progname) @ignored = [] end |
Instance Method Details
#deprecate(old, new = nil, id: []) { ... } ⇒ Object
Marks code as deprecated with/without replacement.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'build/rb/lib/selenium/webdriver/common/logger.rb', line 114 def deprecate(old, new = nil, id: [], &block) id = Array(id) return if @ignored.include?(:deprecations) || (@ignored & id).any? ids = id.empty? ? '' : "[#{id.map(&:inspect).join(', ')}] " = +"[DEPRECATION] #{ids}#{old} is deprecated" << if new ". Use #{new} instead." else ' and will be removed in a future release.' end warn , &block end |
#ignore(id) ⇒ Object
Will not log the provided ID.
85 86 87 |
# File 'build/rb/lib/selenium/webdriver/common/logger.rb', line 85 def ignore(id) Array(id).each { |ignore| @ignored << ignore } 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.
76 77 78 |
# File 'build/rb/lib/selenium/webdriver/common/logger.rb', line 76 def io @logger.instance_variable_get(:@logdev).dev end |
#output=(io) ⇒ Object
Changes logger output to a new IO.
61 62 63 |
# File 'build/rb/lib/selenium/webdriver/common/logger.rb', line 61 def output=(io) @logger.reopen(io) end |
#warn(message, id: []) { ... } ⇒ Object
Overrides default #warn to skip ignored messages by provided id
96 97 98 99 100 101 102 103 104 |
# File 'build/rb/lib/selenium/webdriver/common/logger.rb', line 96 def warn(, id: []) id = Array(id) return if (@ignored & id).any? msg = id.empty? ? : "[#{id.map(&:inspect).join(', ')}] #{} " msg += " #{yield}" if block_given? @logger.warn { msg } end |