class EasyE

Public Class Methods

logger(logfile) click to toggle source
# File lib/easy_e.rb, line 13
def self.logger logfile
  unless @@logger
    @@logger = Logger.new(logfile || STDOUT)
    @@logger.level = Logger::DEBUG
    @@logger.formatter = proc do |severity, datetime, progname, msg|
      "[#{severity}] #{datetime.strftime("%Y-%m-%d %H:%M:%S")} #{msg}\n"
    end
  end

  @@logger
end

Public Instance Methods

execute() click to toggle source
# File lib/easy_e.rb, line 55
def execute
  option_parser.parse!
  logger.debug "Debug logging enabled"
  run
end
logger() click to toggle source
# File lib/easy_e.rb, line 61
def logger
  # HACK -- the logfile argument only gets used on the first invocation
  EasyE.logger options.logfile
end
options() click to toggle source
# File lib/easy_e/options.rb, line 47
def options
  @options ||= OpenStruct.new
end
plugins() click to toggle source
# File lib/easy_e.rb, line 25
def plugins
  @plugins ||= registered_plugins.collect { |klass| klass.new }
end
registered_plugins() click to toggle source
# File lib/easy_e.rb, line 29
def registered_plugins
  EasyE::Plugin.registered_plugins
end
run() click to toggle source
# File lib/easy_e.rb, line 33
def run
  plugins.each do |plugin|
    begin
      plugin.before if plugin.options.enable
    rescue Exception => e
      logger.error "Encountered error while running the #{plugin.name} plugin's before hook"
      logger.error e
    end
  end

  take_snapshots

  plugins.each do |plugin|
    begin
      plugin.after if plugin.options.enable
    rescue Exception => e
      logger.error "Encountered error while running the #{plugin.name} plugin's after hook"
      logger.error e
    end
  end
end