Class: CASClient::LoggerWrapper
- Inherits:
-
Object
- Object
- CASClient::LoggerWrapper
- Defined in:
- lib/casclient.rb
Overview
Wraps a real Logger. If no real Logger is set, then this wrapper will quietly swallow any logging calls.
Instance Method Summary collapse
-
#initialize(real_logger = nil) ⇒ LoggerWrapper
constructor
A new instance of LoggerWrapper.
-
#method_missing(name, *args) ⇒ Object
Log using the appropriate method if we have a logger if we dont’ have a logger, gracefully ignore.
-
#set_real_logger(real_logger) ⇒ Object
Assign the ‘real’ Logger instance that this dummy instance wraps around.
Constructor Details
#initialize(real_logger = nil) ⇒ LoggerWrapper
Returns a new instance of LoggerWrapper.
48 49 50 |
# File 'lib/casclient.rb', line 48 def initialize(real_logger=nil) set_logger(real_logger) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
Log using the appropriate method if we have a logger if we dont’ have a logger, gracefully ignore.
57 58 59 60 61 |
# File 'lib/casclient.rb', line 57 def method_missing(name, *args) if @real_logger && @real_logger.respond_to?(name) @real_logger.send(name, *args) end end |
Instance Method Details
#set_real_logger(real_logger) ⇒ Object
Assign the ‘real’ Logger instance that this dummy instance wraps around.
52 53 54 |
# File 'lib/casclient.rb', line 52 def set_real_logger(real_logger) @real_logger = real_logger end |