Class: Propel::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/propel/logger.rb

Constant Summary collapse

COLORS =
{
    :red    => 31,
    :green  => 32,
    :yellow => 33,
}

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Logger

Returns a new instance of Logger.



9
10
11
# File 'lib/propel/logger.rb', line 9

def initialize(configuration)
  @configuration = configuration
end

Instance Method Details



13
14
15
16
17
18
# File 'lib/propel/logger.rb', line 13

def print(message, color_sym = nil)
  unless @configuration[:quiet]
    Kernel.print color(message, color_sym)
    STDOUT.flush
  end
end

#puts(message, color_sym = nil) ⇒ Object



20
21
22
# File 'lib/propel/logger.rb', line 20

def puts(message, color_sym = nil)
  Kernel.puts color(message, color_sym)
end

#report_operation(message) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/propel/logger.rb', line 28

def report_operation(message)
  if @configuration[:verbose]
    Kernel.puts("#{message}...")
  else
    Kernel.print("%-60s" % "#{message}:")
    STDOUT.flush
  end
end

#report_status(message, color_sym) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/propel/logger.rb', line 37

def report_status(message, color_sym)
  if @configuration[:verbose]
    Kernel.puts(color(message.capitalize, color_sym))
  else
    Kernel.puts("[ #{color(message.upcase, color_sym)} ]")
  end
end

#warn(message, color_sym = nil) ⇒ Object



24
25
26
# File 'lib/propel/logger.rb', line 24

def warn(message, color_sym = nil)
  Kernel.warn color(message, color_sym)
end