Class: Hiera::FallbackLogger Private
- Inherits:
-
Object
- Object
- Hiera::FallbackLogger
- Defined in:
- lib/hiera/fallback_logger.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Select from a given list of loggers the first one that it suitable and use that as the actual logger
Instance Method Summary collapse
- #debug(message) ⇒ Object private
-
#initialize(*implementations) ⇒ FallbackLogger
constructor
private
Chooses the first suitable logger.
- #warn(message) ⇒ Object private
Constructor Details
#initialize(*implementations) ⇒ FallbackLogger
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.
Chooses the first suitable logger. For all of the loggers that are unsuitable it will issue a warning using the suitable logger stating that the unsuitable logger is not being used.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hiera/fallback_logger.rb', line 12 def initialize(*implementations) warnings = [] @implementation = implementations.find do |impl| if impl.respond_to?(:suitable?) if impl.suitable? true else warnings << "Not using #{impl.name}. It does not report itself to be suitable." false end else true end end if @implementation.nil? raise "No suitable logging implementation found." end warnings.each { || warn() } end |
Instance Method Details
#debug(message) ⇒ 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.
38 39 40 |
# File 'lib/hiera/fallback_logger.rb', line 38 def debug() @implementation.debug() end |
#warn(message) ⇒ 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.
34 35 36 |
# File 'lib/hiera/fallback_logger.rb', line 34 def warn() @implementation.warn() end |