Module: Berkshelf::API::Logging

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.loggerLogger

Returns:

  • (Logger)


5
6
7
# File 'lib/berkshelf/api/logging.rb', line 5

def logger
  @logger
end

Class Method Details

.init(options = {}) ⇒ Logger

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :location (String, Fixnum) — default: STDOUT
  • :level (String, nil) — default: "INFO"
    • “DEBUG

    • “INFO”

    • “WARN”

    • “ERROR”

    • “FATAL”

  • :formatter (Logger::Formatter)

Returns:

  • (Logger)


17
18
19
20
21
22
23
24
25
26
# File 'lib/berkshelf/api/logging.rb', line 17

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

Instance Method Details

#loggerLogger Also known as: log

Returns:

  • (Logger)


32
33
34
# File 'lib/berkshelf/api/logging.rb', line 32

def logger
  Logging.logger
end