Module: Dexter::Logging

Included in:
Client, Client, Indexer, LogParser, Processor
Defined in:
lib/dexter/logging.rb

Constant Summary collapse

COLOR_CODES =
{
  red: 31,
  green: 32,
  yellow: 33,
  cyan: 36
}

Instance Method Summary collapse

Instance Method Details

#colorize(message, color) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/dexter/logging.rb', line 18

def colorize(message, color)
  if output.tty?
    "\e[#{COLOR_CODES[color]}m#{message}\e[0m"
  else
    message
  end
end

#log(message = "") ⇒ Object



14
15
16
# File 'lib/dexter/logging.rb', line 14

def log(message = "")
  output.puts(message) unless $log_level == "error"
end

#outputObject



10
11
12
# File 'lib/dexter/logging.rb', line 10

def output
  $stdout
end