Class: BBK::App::ProxyLogger
- Inherits:
-
Object
- Object
- BBK::App::ProxyLogger
- Defined in:
- lib/bbk/app/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?(*args) ⇒ Boolean
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(logger, tags:) ⇒ ProxyLogger
Returns a new instance of ProxyLogger.
9 10 11 12 13 |
# File 'lib/bbk/app/proxy_logger.rb', line 9 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
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bbk/app/proxy_logger.rb', line 20 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.
7 8 9 |
# File 'lib/bbk/app/proxy_logger.rb', line 7 def logger @logger end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
7 8 9 |
# File 'lib/bbk/app/proxy_logger.rb', line 7 def @tags end |
Instance Method Details
#add_tags(*tags) ⇒ Object
15 16 17 18 |
# File 'lib/bbk/app/proxy_logger.rb', line 15 def (*) @tags += .flatten @tags = @tags.uniq end |
#respond_to?(*args) ⇒ Boolean
31 32 33 |
# File 'lib/bbk/app/proxy_logger.rb', line 31 def respond_to?(*args) logger.send(:respond_to?, *args) || super end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
35 36 37 |
# File 'lib/bbk/app/proxy_logger.rb', line 35 def respond_to_missing?(method_name, include_private = false) logger.send(:respond_to_missing?, method_name, include_private) || super end |