Module: Rebi::Log

Included in:
Rebi, Application, EC2, Environment, ZipHelper
Defined in:
lib/rebi/log.rb

Instance Method Summary collapse

Instance Method Details

#colorize(mes, opts = {}) ⇒ Object



50
51
52
# File 'lib/rebi/log.rb', line 50

def colorize mes, opts={}
  ColorizedString[mes].colorize(opts)
end

#colorize_prefix(prefix) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/rebi/log.rb', line 19

def colorize_prefix(prefix)
  colors = ColorizedString.colors
  colors.delete :light_black
  h = prefix.chars.inject(0) do |m, c|
    m + c.ord
  end
  return colorize(prefix, color: colors[h % colors.count], background: :light_black)
end

#error(mes, label = self.error_label) ⇒ Object



7
8
9
# File 'lib/rebi/log.rb', line 7

def error mes, label=self.error_label
  puts colorize(label, color: :white, background: :red) + ": " + mes
end

#error_labelObject



15
16
17
# File 'lib/rebi/log.rb', line 15

def error_label
  "ERROR"
end

#h1(s) ⇒ Object



28
29
30
# File 'lib/rebi/log.rb', line 28

def h1 s
  colorize(s, color: :light_yellow, background: :light_blue)
end

#h2(s) ⇒ Object



32
33
34
# File 'lib/rebi/log.rb', line 32

def h2 s
  colorize(s, color: :light_blue, background: :light_cyan)
end

#h3(s) ⇒ Object



36
37
38
# File 'lib/rebi/log.rb', line 36

def h3 s
  colorize(s, color: :light_yellow, background: :light_blue, mode: :bold)
end

#h4(s) ⇒ Object



40
41
42
# File 'lib/rebi/log.rb', line 40

def h4 s
  colorize(s, color: :black, background: :green, mode: :italic)
end

#hstatus(s) ⇒ Object



44
45
46
47
48
# File 'lib/rebi/log.rb', line 44

def hstatus s
  bg = s.downcase.to_sym
  bg = :light_black unless ColorizedString.colors.include?(bg)
  colorize(s, color: :black, background: bg, mode: :italic)
end

#log(mes, label = self.log_label) ⇒ Object



3
4
5
# File 'lib/rebi/log.rb', line 3

def log mes, label=self.log_label
    puts "#{label ? "#{colorize_prefix(label)}: " : ""}#{mes}"
end

#log_labelObject



11
12
13
# File 'lib/rebi/log.rb', line 11

def log_label
  "Rebi"
end