Class: GrayLogger::Proxy
- Inherits:
-
Object
- Object
- GrayLogger::Proxy
- Defined in:
- lib/gray_logger/proxy.rb
Instance Attribute Summary collapse
-
#proxied_logger ⇒ Object
Returns the value of attribute proxied_logger.
Instance Method Summary collapse
- #gray_logger ⇒ Object
- #gray_logger? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Proxy
constructor
A new instance of Proxy.
- #initialize_gray_logger! ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Proxy
Returns a new instance of Proxy.
5 6 7 8 |
# File 'lib/gray_logger/proxy.rb', line 5 def initialize(attributes={}) self.proxied_logger = attributes[:proxied_logger] @gray_logger = attributes[:gray_logger] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object (private)
delegate every method the proxy doesn’t know to gray_logger and proxied_logger. let them handle this.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/gray_logger/proxy.rb', line 49 def method_missing(method_name, *args, &block) unless proxied_logger.nil? begin proxied_logger.send(method_name, *args, &block) rescue => e proxied_logger.error(e.backtrace.join("\n")) end else super end end |
Instance Attribute Details
#proxied_logger ⇒ Object
Returns the value of attribute proxied_logger.
3 4 5 |
# File 'lib/gray_logger/proxy.rb', line 3 def proxied_logger @proxied_logger end |
Instance Method Details
#gray_logger ⇒ Object
10 11 12 |
# File 'lib/gray_logger/proxy.rb', line 10 def gray_logger @gray_logger end |
#gray_logger? ⇒ Boolean
14 15 16 |
# File 'lib/gray_logger/proxy.rb', line 14 def gray_logger? !!@gray_logger end |
#initialize_gray_logger! ⇒ Object
18 19 20 |
# File 'lib/gray_logger/proxy.rb', line 18 def initialize_gray_logger! @gray_logger = ::GrayLogger::Logger.new(::GrayLogger.configuration) end |