Class: Dry::Monitor::LDAP::Logger
- Inherits:
-
Object
- Object
- Dry::Monitor::LDAP::Logger
- Extended by:
- Configurable, Core::Extensions
- Defined in:
- lib/dry/monitor/ldap/logger.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(logger, config = self.class.config) ⇒ Logger
constructor
A new instance of Logger.
- #log_query(time, name, query) ⇒ Object
- #subscribe(notifications) ⇒ Object
Constructor Details
#initialize(logger, config = self.class.config) ⇒ Logger
Returns a new instance of Logger.
40 41 42 43 44 |
# File 'lib/dry/monitor/ldap/logger.rb', line 40 def initialize(logger, config = self.class.config) @logger = logger @config = config @template = config. end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
33 34 35 |
# File 'lib/dry/monitor/ldap/logger.rb', line 33 def config @config end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
34 35 36 |
# File 'lib/dry/monitor/ldap/logger.rb', line 34 def logger @logger end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
35 36 37 |
# File 'lib/dry/monitor/ldap/logger.rb', line 35 def template @template end |
Instance Method Details
#log_query(time, name, query) ⇒ Object
52 53 54 |
# File 'lib/dry/monitor/ldap/logger.rb', line 52 def log_query(time, name, query) logger.info template % [name.inspect, time, colorizer.call(query)] end |
#subscribe(notifications) ⇒ Object
46 47 48 49 50 |
# File 'lib/dry/monitor/ldap/logger.rb', line 46 def subscribe(notifications) notifications.subscribe(:ldap) do |time:, name:, query:| log_query(time, name, query) end end |