Class: Selenium::WebDriver::Logger
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Logger
- Extended by:
- Forwardable
- Defined in:
- rb/lib/selenium/webdriver/common/logger.rb
Overview
Instance Method Summary collapse
-
#allow(*ids) ⇒ Object
Will only log the provided ID.
-
#debug(message, id: []) { ... } ⇒ Object
Used to supply information of interest for debugging a problem Overrides default #debug to skip ignored messages by provided id.
-
#deprecate(old, new = nil, id: [], reference: '') { ... } ⇒ Object
Marks code as deprecated with/without replacement.
-
#error(message, id: []) { ... } ⇒ Object
Used to supply information that suggests an error occurred.
-
#ignore(*ids) ⇒ Object
Will not log the provided ID.
-
#info(message, id: []) { ... } ⇒ Object
Used to supply information of general interest.
-
#initialize(progname = 'Selenium', default_level: nil, ignored: nil, allowed: nil) ⇒ Logger
constructor
A new instance of Logger.
-
#io ⇒ Object
private
Returns IO object used by logger internally.
- #level=(level) ⇒ Object
-
#output=(io) ⇒ Object
Changes logger output to a new IO.
-
#warn(message, id: []) { ... } ⇒ Object
Used to supply information that suggests action be taken by user.
Constructor Details
#initialize(progname = 'Selenium', default_level: nil, ignored: nil, allowed: nil) ⇒ Logger
Returns a new instance of Logger.
51 52 53 54 55 56 57 58 |
# File 'rb/lib/selenium/webdriver/common/logger.rb', line 51 def initialize(progname = 'Selenium', default_level: nil, ignored: nil, allowed: nil) default_level ||= $DEBUG || ENV.key?('DEBUG') ? :debug : :warn @logger = create_logger(progname, level: default_level) @ignored = Array(ignored) @allowed = Array(allowed) @first_warning = false end |
Instance Method Details
#allow(*ids) ⇒ Object
Will only log the provided ID.
106 107 108 |
# File 'rb/lib/selenium/webdriver/common/logger.rb', line 106 def allow(*ids) @allowed += Array(ids).flatten end |
#debug(message, id: []) { ... } ⇒ Object
Used to supply information of interest for debugging a problem Overrides default #debug to skip ignored messages by provided id
118 119 120 |
# File 'rb/lib/selenium/webdriver/common/logger.rb', line 118 def debug(, id: [], &block) discard_or_log(:debug, , id, &block) end |
#deprecate(old, new = nil, id: [], reference: '') { ... } ⇒ Object
Marks code as deprecated with/without replacement.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'rb/lib/selenium/webdriver/common/logger.rb', line 164 def deprecate(old, new = nil, id: [], reference: '', &block) id = Array(id) return if @ignored.include?(:deprecations) id << :deprecations if @allowed.include?(:deprecations) = "[DEPRECATION] #{old} is deprecated" << if new ". Use #{new} instead." else ' and will be removed in a future release.' end << " See explanation for this deprecation: #{reference}." unless reference.empty? discard_or_log(:warn, , id, &block) end |
#error(message, id: []) { ... } ⇒ Object
Used to supply information that suggests an error occurred
140 141 142 |
# File 'rb/lib/selenium/webdriver/common/logger.rb', line 140 def error(, id: [], &block) discard_or_log(:error, , id, &block) end |
#ignore(*ids) ⇒ Object
Will not log the provided ID.
97 98 99 |
# File 'rb/lib/selenium/webdriver/common/logger.rb', line 97 def ignore(*ids) @ignored += Array(ids).flatten end |
#info(message, id: []) { ... } ⇒ Object
Used to supply information of general interest
129 130 131 |
# File 'rb/lib/selenium/webdriver/common/logger.rb', line 129 def info(, id: [], &block) discard_or_log(:info, , id, &block) 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.
88 89 90 |
# File 'rb/lib/selenium/webdriver/common/logger.rb', line 88 def io @logger.instance_variable_get(:@logdev).dev end |
#level=(level) ⇒ Object
60 61 62 63 64 65 66 |
# File 'rb/lib/selenium/webdriver/common/logger.rb', line 60 def level=(level) if level == :info && @logger.level == :info info(':info is now the default log level, to see additional logging, set log level to :debug') end @logger.level = level end |
#output=(io) ⇒ Object
Changes logger output to a new IO.
73 74 75 |
# File 'rb/lib/selenium/webdriver/common/logger.rb', line 73 def output=(io) @logger.reopen(io) end |
#warn(message, id: []) { ... } ⇒ Object
Used to supply information that suggests action be taken by user
151 152 153 |
# File 'rb/lib/selenium/webdriver/common/logger.rb', line 151 def warn(, id: [], &block) discard_or_log(:warn, , id, &block) end |