lib/splash/exiter.rb in prometheus-splash-0.3.0 vs lib/splash/exiter.rb in prometheus-splash-0.4.0
- old
+ new
@@ -1,8 +1,9 @@
# coding: utf-8
module Splash
module Exiter
+ include Splash::Loggers
EXIT_MAP= {
# context execution
:not_root => {:message => "This operation need to be run as root (use sudo or rvmsudo)", :code => 10},
:options_incompatibility => {:message => "Options incompatibility", :code => 40},
@@ -32,18 +33,19 @@
:status_ko => {:message => "Status KO", :code => 31}
}
def splash_exit(options = {})
+ log = get_logger
mess = ""
mess = EXIT_MAP[options[:case]][:message] if EXIT_MAP[options[:case]].include? :message
mess << " : " unless mess.empty? or not options[:more]
mess << "#{options[:more]}" if options[:more]
if EXIT_MAP[options[:case]][:code] == 0 then
- puts mess unless mess.empty?
+ log.success mess unless mess.empty?
exit 0
else
- $stderr.puts mess unless mess.empty?
+ log.fatal mess unless mess.empty?
exit EXIT_MAP[options[:case]][:code]
end
end