Module: Dr::Logger

Included in:
BuildRoot, GnuPG, Package, Package, Repo, ShellCmd
Defined in:
lib/dr/logger.rb

Constant Summary collapse

@@logger_options =
{
  :info => "info",
  :warn => "warn",
  :err  => "err",
  :debug => "debug"
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.log(level, msg) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/dr/logger.rb', line 83

def self.log(level, msg)
  out = "dr".style("log-head") << " "

  case level
  when :info  then out << "info".style(@@logger_options[:info])
  when :warn  then out << "WARN".style(@@logger_options[:warn])
  when :err   then out << "ERR!".style(@@logger_options[:err])
  when :debug then out << "dbg?".style(@@logger_options[:debug])
  end

  out << " " << msg.chomp
  puts out
  STDOUT.flush
end

Instance Method Details

#log(level, msg) ⇒ Object



98
99
100
# File 'lib/dr/logger.rb', line 98

def log(level, msg)
  Logger::log level, msg
end

#tag(tag, msg) ⇒ Object



102
103
104
# File 'lib/dr/logger.rb', line 102

def tag(tag, msg)
  tag.fg("blue").bg("dark-grey") << " " << msg
end