Class: CASClient::LoggerWrapper

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(real_logger = nil) ⇒ LoggerWrapper

Returns a new instance of LoggerWrapper.



49
50
51
# File 'lib/casclient.rb', line 49

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.



58
59
60
61
62
# File 'lib/casclient.rb', line 58

def method_missing(name, *args)
  if !@real_logger.nil? && @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.



53
54
55
# File 'lib/casclient.rb', line 53

def set_real_logger(real_logger)
  @real_logger = real_logger
end