Module: Bunnish

Defined in:
lib/bunnish.rb,
lib/bunnish.rb

Defined Under Namespace

Modules: Command, Core

Class Method Summary collapse

Class Method Details

.default_loggerObject



31
32
33
34
35
36
# File 'lib/bunnish.rb', line 31

def self.default_logger
  require 'logger'
  l = Logger.new(STDERR)
  l.level = Logger::INFO
  l
end

.loggerObject



16
17
18
19
20
21
22
23
24
# File 'lib/bunnish.rb', line 16

def self.logger
  if @logger.nil?
    @logger = (rails_logger || default_logger)
    @logger.formatter = proc { |severity, datetime, progname, msg|
      datetime.strftime("[%Y-%m-%d %H:%M:%S](#{severity})#{msg}\n")
    }
  end
  return @logger
end

.logger=(logger) ⇒ Object



38
39
40
# File 'lib/bunnish.rb', line 38

def self.logger=(logger)
  @logger = logger
end

.parse_opts(argv) ⇒ Object



12
13
14
# File 'lib/bunnish.rb', line 12

def self.parse_opts(argv)
  return Bunnish::Core::Common::parse_opts(argv)
end

.rails_loggerObject



26
27
28
29
# File 'lib/bunnish.rb', line 26

def self.rails_logger
  (defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger) ||
  (defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER.respond_to?(:debug) && RAILS_DEFAULT_LOGGER)
end