Class: Navvy::Logger

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

Instance Method Summary collapse

Constructor Details

#initialize(logdev = STDOUT) ⇒ Logger

Create a new logger. Works like Logger from Ruby’s standard library, but defaults to STDOUT instead of failing. You can pass a filename to log to.

Examples:

logger = Navvy::Logger.new
logger = Navvy::Logger.new('~/file.log')


15
16
17
# File 'lib/navvy/logger.rb', line 15

def initialize(logdev = STDOUT)
  super logdev
end

Instance Method Details

#colorized_info(message, color) ⇒ Object

Send colored logs to the logger. Will only colorize output sent to STDOUT and will call the regular info method when writing to file.

message

Examples:

logger = Navvy::Logger.new
logger.colorized_info "I'm green!", 32


31
32
33
34
35
36
# File 'lib/navvy/logger.rb', line 31

def colorized_info(message, color)
  unless @logdev.filename
    return info("\e[#{color}m#{message}\e[0m")
  end
  info(message)
end