lib/splash/loggers.rb in prometheus-splash-0.5.0 vs lib/splash/loggers.rb in prometheus-splash-0.5.2

- old
+ new

@@ -8,36 +8,37 @@ @@logger=nil def get_logger(options = {}) logger = (get_config.loggers[:list].include? options[:logger])? options[:logger].to_s : get_config.loggers[:default].to_s aclass = "Splash::Loggers::#{logger.capitalize}" -# begin + begin return @@logger = Kernel.const_get(aclass)::new if options[:force] return @@logger ||= Kernel.const_get(aclass)::new -# rescue -# splash_exit case: :configuration_error, more: "Logger specified inexistant : #{logger}" -# end + rescue + splash_exit case: :configuration_error, more: "Logger specified inexistant : #{logger}" + end end def get_session return "#{Time.now.to_i.to_s}#{rand(999)}" end def change_logger(options = {}) + level = get_logger.level options[:force] = true - get_logger(options) + get_logger(options).level = level end + LEVELS = [:debug, :warn, :info, :result, :fatal, :unknown] + ALIAS = {:flat => :info, :item => :info, :ok => :info, :ko => :info, :trigger => :info, + :schedule => :info, :arrow => :info, :send => :info, + :receive => :info, :error => :result, :success => :result } - class LoggerTemplate include Splash::Config - LEVELS = [:debug, :warn, :info, :result, :fatal, :unknown] - ALIAS = {:flat => :info, :item => :info, :ok => :info, :ko => :info, :trigger => :info, - :schedule => :info, :arrow => :info, :send => :info, - :receive => :info, :error => :result, :success => :result } + LEVELS.each do |method| define_method(method) do |message,session = ''| self.log({ :level => method, :message => message, :session => session}) end end