Module: Cawcaw

Defined in:
lib/cawcaw.rb,
lib/cawcaw.rb,
lib/cawcaw/core/common.rb,
lib/cawcaw/command/mysql.rb,
lib/cawcaw/command/hadoop.rb,
lib/cawcaw/command/database.rb,
lib/cawcaw/command/rabbitmq.rb,
lib/cawcaw/command/hadoop/dfs.rb,
lib/cawcaw/command/postgresql.rb,
lib/cawcaw/command/mysql/table.rb,
lib/cawcaw/command/database/table.rb,
lib/cawcaw/command/postgresql/table.rb,
lib/cawcaw/command/rabbitmq/queue_count.rb

Defined Under Namespace

Modules: Command, Core

Class Method Summary collapse

Class Method Details

.default_loggerObject



37
38
39
40
41
# File 'lib/cawcaw.rb', line 37

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

.loggerObject



22
23
24
25
26
27
28
29
30
# File 'lib/cawcaw.rb', line 22

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



43
44
45
# File 'lib/cawcaw.rb', line 43

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

.parse_opts(argv) ⇒ Object



18
19
20
# File 'lib/cawcaw.rb', line 18

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

.rails_loggerObject



32
33
34
35
# File 'lib/cawcaw.rb', line 32

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