Module: Mongo::Deprecations Private
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
Loggable,
self
|
|
| Defined in: | lib/mongo/deprecations.rb |
Overview
Used for reporting deprecated behavior in the driver. When it is possible to detect that a deprecated feature is being used, a warning should be issued through this module.
The warning will be issued no more than once for that feature, regardless of how many times Deprecations.warn is called.
Constant Summary
-
MUTEX =
# File 'lib/mongo/deprecations.rb', line 23
Mutex for synchronizing access to warned features.
Thread::Mutex.new
Class Method Summary
Loggable - Extended
| log_debug | Convenience method to log debug messages with the standard prefix. |
| log_error | Convenience method to log error messages with the standard prefix. |
| log_fatal | Convenience method to log fatal messages with the standard prefix. |
| log_info | Convenience method to log info messages with the standard prefix. |
| log_warn | Convenience method to log warn messages with the standard prefix. |
| logger | Get the logger instance. |
| _mongo_log_prefix, format_message | |
Instance Method Summary
-
#clear!
Internal use only
Clears all memory of previously warned features.
-
#warn(feature, message)
Internal use only
Issue a warning about a deprecated feature.
-
#warned!(feature)
Internal use only
Mark that a warning for a given deprecated feature has been issued.
-
#warned?(feature, prefix: false) ⇒ true | false
Internal use only
Check if a warning for a given deprecated feature has already been issued.
-
#_warned!(feature)
private
Internal use only
Mark that a warning for a given deprecated feature has been issued.
-
#_warned?(feature, prefix: false) ⇒ true | false
private
Internal use only
Check if a warning for a given deprecated feature has already been issued.
-
#warned_features(reset: false) ⇒ Set<String>
private
Internal use only
Set of features that have already been warned about.
Instance Method Details
#_warned!(feature) (private)
Mark that a warning for a given deprecated feature has been issued. This version is not thread-safe.
# File 'lib/mongo/deprecations.rb', line 94
def _warned!(feature) warned_features.add(feature.to_s) end
#_warned?(feature, prefix: false) ⇒ true | false (private)
Check if a warning for a given deprecated feature has already been issued. This version is not thread-safe.
# File 'lib/mongo/deprecations.rb', line 82
def _warned?(feature, prefix: false) if prefix warned_features.any? { |f| f.to_s.start_with?(feature) } else warned_features.include?(feature.to_s) end end
#clear!
Clears all memory of previously warned features.
# File 'lib/mongo/deprecations.rb', line 58
def clear! MUTEX.synchronize { warned_features reset: true } nil end
#warn(feature, message)
Issue a warning about a deprecated feature. The warning is written to the logger, and will not be written more than once per feature.
#warned!(feature)
Mark that a warning for a given deprecated feature has been issued.
#warned?(feature, prefix: false) ⇒ true | false
Check if a warning for a given deprecated feature has already been issued.
#warned_features(reset: false) ⇒ Set<String> (private)
Set of features that have already been warned about.
# File 'lib/mongo/deprecations.rb', line 70
def warned_features(reset: false) @warned_features = nil if reset @warned_features ||= Set.new end