Class: BBK::Utils::ProxyLogger
- Inherits:
-
Object
- Object
- BBK::Utils::ProxyLogger
- Defined in:
- lib/bbk/utils/proxy_logger.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #add_tags(*tags) ⇒ Object
-
#initialize(logger, tags:) ⇒ ProxyLogger
constructor
A new instance of ProxyLogger.
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to?(name, include_private = false) ⇒ Boolean
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(logger, tags:) ⇒ ProxyLogger
Returns a new instance of ProxyLogger.
11 12 13 14 15 |
# File 'lib/bbk/utils/proxy_logger.rb', line 11 def initialize(logger, tags:) @logger = logger @tagged = @logger.respond_to?(:tagged) @tags = [].flatten end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bbk/utils/proxy_logger.rb', line 22 def method_missing(method, *args, &block) super unless logger.respond_to?(method) if @tagged = - logger.formatter. logger.tagged() { logger.send(method, *args, &block) } else logger.send(method, *args, &block) end end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
9 10 11 |
# File 'lib/bbk/utils/proxy_logger.rb', line 9 def logger @logger end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
9 10 11 |
# File 'lib/bbk/utils/proxy_logger.rb', line 9 def @tags end |
Instance Method Details
#add_tags(*tags) ⇒ Object
17 18 19 20 |
# File 'lib/bbk/utils/proxy_logger.rb', line 17 def (*) @tags += .flatten @tags = @tags.uniq end |
#respond_to?(name, include_private = false) ⇒ Boolean
33 34 35 |
# File 'lib/bbk/utils/proxy_logger.rb', line 33 def respond_to?(name, include_private=false) logger.send(:respond_to?, name, include_private) || super end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
37 38 39 |
# File 'lib/bbk/utils/proxy_logger.rb', line 37 def respond_to_missing?(method_name, include_private = false) logger.send(:respond_to_missing?, method_name, include_private) || super end |