Ruby: Basic implementation of Logger class using Thor cli.
... just so I don't have to look for this again, ever.
require 'thor' | |
require 'logger' | |
class_option :verbose, :type => :boolean, :aliases => "-v" | |
class_option :debug, :type => :boolean, :aliases => "-d" | |
class_option :quiet, :type => :boolean, :aliases => "-q" | |
def initialize(*args) | |
@log = Logger.new(STDOUT) | |
if options[:debug] | |
@log.level = Logger::DEBUG | |
@log.info("Logger level set to DEBUG") | |
elsif options[:verbose] | |
@log.level = Logger::INFO | |
@log.info("Logger level set to INFO") | |
elsif options[:quiet] | |
@log.level = Logger::ERROR | |
@log.info("Logger level set to ERROR") | |
else | |
@log.level = Logger::WARN | |
@log.info("Logger level defaulting to WARN") | |
end | |
end |
Ruby: Basic implementation of Logger class using Thor cli.
... just so I don't have to look for this again, ever.