Class: AD::LDAP::Logger
- Inherits:
-
Object
- Object
- AD::LDAP::Logger
- Defined in:
- lib/ad-ldap/logger.rb
Overview
Inspired by github.com/tpett/perry logger
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#silent ⇒ Object
Returns the value of attribute silent.
Instance Method Summary collapse
-
#initialize(config) ⇒ Logger
constructor
A new instance of Logger.
- #out(method, args, result, time) ⇒ Object
Constructor Details
#initialize(config) ⇒ Logger
Returns a new instance of Logger.
8 9 10 11 |
# File 'lib/ad-ldap/logger.rb', line 8 def initialize(config) self.logger = config.logger self.silent = !!config.silent end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/ad-ldap/logger.rb', line 6 def logger @logger end |
#silent ⇒ Object
Returns the value of attribute silent.
6 7 8 |
# File 'lib/ad-ldap/logger.rb', line 6 def silent @silent end |
Instance Method Details
#out(method, args, result, time) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ad-ldap/logger.rb', line 13 def out(method, args, result, time) color = "4;32;1" name = "%s (%.1fms)" % [ "LDAP", time ] = self.(method, args) output = " \e[#{color}m#{name} #{}\e[0m" if self.logger self.logger.debug(output) elsif !self.silent puts output end end |