Sha256: eeb7676d1b1b8b961e8df7410af6a8f741fdc5c6383e9d2e14519cb17b40f150

Contents?: true

Size: 1.15 KB

Versions: 22

Compression:

Stored size: 1.15 KB

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')
      if type == 'debug'
        if Application::instance.options.respond_to?('has_key') and Application::instance.options.has_key?('debug')
          logger.send(type, "#{prefix} - #{message}")
        end
      else
        logger.send(type, "#{prefix} - #{message}")
      end
    end

    def prefix
    end

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
docman-0.0.107 lib/docman/logging.rb
docman-0.0.106 lib/docman/logging.rb
docman-0.0.105 lib/docman/logging.rb
docman-0.0.104 lib/docman/logging.rb
docman-0.0.103 lib/docman/logging.rb
docman-0.0.102 lib/docman/logging.rb
docman-0.0.101 lib/docman/logging.rb
docman-0.0.100 lib/docman/logging.rb
docman-0.0.99 lib/docman/logging.rb
docman-0.0.98 lib/docman/logging.rb
docman-0.0.97 lib/docman/logging.rb
docman-0.0.96 lib/docman/logging.rb
docman-0.0.95 lib/docman/logging.rb
docman-0.0.94 lib/docman/logging.rb
docman-0.0.93 lib/docman/logging.rb
docman-0.0.92 lib/docman/logging.rb
docman-0.0.91 lib/docman/logging.rb
docman-0.0.90 lib/docman/logging.rb
docman-0.0.89 lib/docman/logging.rb
docman-0.0.88 lib/docman/logging.rb