Sha256: b136e3f0c4a99b236794120746a6605bea0fb34803a03804ae3fc1ec3196df9c

Contents?: true

Size: 950 Bytes

Versions: 79

Compression:

Stored size: 950 Bytes

Contents

module Docman
  module Logging

    def logger
      Logging.logger
    end

    def self.logger
      @logger ||= Logger.new(STDOUT)
    end

    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

    def with_logging(message = nil, type = 'debug')
      # logger.send(type, "#{prefix} - #{message} - start") if @log
      log("#{message} - start", type)
      result = yield
      log("#{message} - finish", type)
      # logger.send(type, "#{prefix} - #{message} - finish") if @log
      result
    end

    def log(message, type = 'debug')
      logger.send(type, "#{prefix} - #{message}")
    end

    def prefix
    end

  end
end

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
docman-0.0.84 lib/docman/logging.rb
docman-0.0.83 lib/docman/logging.rb
docman-0.0.82 lib/docman/logging.rb
docman-0.0.81 lib/docman/logging.rb
docman-0.0.80 lib/docman/logging.rb
docman-0.0.79 lib/docman/logging.rb
docman-0.0.78 lib/docman/logging.rb
docman-0.0.77 lib/docman/logging.rb
docman-0.0.76 lib/docman/logging.rb
docman-0.0.75 lib/docman/logging.rb
docman-0.0.74 lib/docman/logging.rb
docman-0.0.73 lib/docman/logging.rb
docman-0.0.72 lib/docman/logging.rb
docman-0.0.71 lib/docman/logging.rb
docman-0.0.70 lib/docman/logging.rb
docman-0.0.69 lib/docman/logging.rb
docman-0.0.68 lib/docman/logging.rb
docman-0.0.67 lib/docman/logging.rb
docman-0.0.66 lib/docman/logging.rb
docman-0.0.65 lib/docman/logging.rb