Sha256: 8b861d767823b01b2f9bd34164265dc6bf9f492799ca484cafa46f0f2e7e29d0

Contents?: true

Size: 918 Bytes

Versions: 20

Compression:

Stored size: 918 Bytes

Contents

module Berkshelf::API
  module Logging
    class << self
      # @return [Logger]
      attr_accessor :logger

      # @option options [String, Fixnum] :location (STDOUT)
      # @option options [String, nil] :level ("INFO")
      #   - "DEBUG
      #   - "INFO"
      #   - "WARN"
      #   - "ERROR"
      #   - "FATAL"
      # @option options [Logger::Formatter] :formatter
      #
      # @return [Logger]
      def init(options = {})
        level     = options[:level] || "INFO"
        location  = options[:location] || STDOUT
        formatter = options[:formatter] || nil

        Celluloid.logger = @logger = Logger.new(location).tap do |log|
          log.level     = Logger::Severity.const_get(level.upcase)
          log.formatter = formatter if formatter
        end
      end
    end

    init

    # @return [Logger]
    def logger
      Logging.logger
    end
    alias_method :log, :logger
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
berkshelf-api-3.0.0 lib/berkshelf/api/logging.rb
berkshelf-api-2.2.0 lib/berkshelf/api/logging.rb
berkshelf-api-2.1.3 lib/berkshelf/api/logging.rb
berkshelf-api-2.1.2 lib/berkshelf/api/logging.rb
berkshelf-api-2.1.1 lib/berkshelf/api/logging.rb
berkshelf-api-2.1.0 lib/berkshelf/api/logging.rb
berkshelf-api-2.0.0 lib/berkshelf/api/logging.rb
berkshelf-api-1.4.0 lib/berkshelf/api/logging.rb
berkshelf-api-1.3.1 lib/berkshelf/api/logging.rb
berkshelf-api-1.3.0 lib/berkshelf/api/logging.rb
berkshelf-api-1.2.2 lib/berkshelf/api/logging.rb
berkshelf-api-1.2.1 lib/berkshelf/api/logging.rb
berkshelf-api-1.2.0 lib/berkshelf/api/logging.rb
berkshelf-api-1.2.0.rc2 lib/berkshelf/api/logging.rb
berkshelf-api-1.2.0.rc1 lib/berkshelf/api/logging.rb
berkshelf-api-1.1.1 lib/berkshelf/api/logging.rb
berkshelf-api-1.1.0 lib/berkshelf/api/logging.rb
berkshelf-api-1.0.0 lib/berkshelf/api/logging.rb
berkshelf-api-0.2.0 lib/berkshelf/api/logging.rb
berkshelf-api-0.1.0 lib/berkshelf/api/logging.rb