Module: Docman::Logging
Class Method Summary collapse
Instance Method Summary collapse
- #log(message, type = 'debug') ⇒ Object
- #logger ⇒ Object
- #prefix ⇒ Object
- #properties_info(properties = []) ⇒ Object
- #with_logging(message = nil, type = 'debug') ⇒ Object
Class Method Details
.logger ⇒ Object
8 9 10 |
# File 'lib/docman/logging.rb', line 8 def self.logger @logger ||= Logger.new(STDOUT) end |
Instance Method Details
#log(message, type = 'debug') ⇒ Object
33 34 35 |
# File 'lib/docman/logging.rb', line 33 def log(, type = 'debug') logger.send(type, "#{prefix} - #{}") end |
#prefix ⇒ Object
37 38 |
# File 'lib/docman/logging.rb', line 37 def prefix end |
#properties_info(properties = []) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/docman/logging.rb', line 12 def properties_info(properties = []) arr = ["name=#{self.class.name}"] properties.each do |property| if self.is_a? Hash arr << "#{property}=#{self[property]}" if self.include?(property) else arr << "#{property}=#{self.send(property)}" if self.respond_to?(property) end end arr.join(', ') end |
#with_logging(message = nil, type = 'debug') ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/docman/logging.rb', line 24 def with_logging( = nil, type = 'debug') # logger.send(type, "#{prefix} - #{message} - start") if @log log("#{} - start", type) result = yield log("#{} - finish", type) # logger.send(type, "#{prefix} - #{message} - finish") if @log result end |