./lib/le.rb in le-2.2.2 vs ./lib/le.rb in le-2.2.3

- old
+ new

@@ -2,38 +2,38 @@ require 'logger' module Le - def self.new(token, options={}) + def self.new(token, options={}) - self.checkParams(token) + self.checkParams(token) - opt_local = options[:local] || false - opt_debug = options[:debug] || false - opt_ssl = options[:ssl] || false - opt_log_level = options[:log_level] || Logger::DEBUG + opt_local = options[:local] || false + opt_debug = options[:debug] || false + opt_ssl = options[:ssl] || false + opt_log_level = options[:log_level] || Logger::DEBUG - host = Le::Host.new(token, opt_local, opt_debug, opt_ssl) + host = Le::Host.new(token, opt_local, opt_debug, opt_ssl) - if defined?(ActiveSupport::Logger) - logger = ActiveSupport::Logger.new(host) - else - logger = Logger.new(host) - end + if defined?(ActiveSupport::TaggedLogging) + logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(host)) + elsif defined?(ActiveSupport::Logger) + logger = ActiveSupport::Logger.new(host) + logger.formatter = host.formatter if host.respond_to?(:formatter) + else + logger = Logger.new(host) + logger.formatter = host.formatter if host.respond_to?(:formatter) + end - logger.level = opt_log_level - - if host.respond_to?(:formatter) - logger.formatter = host.formatter - end + logger.level = opt_log_level - logger - end + logger + end - def self.checkParams(token) + def self.checkParams(token) # Check if the key is valid UUID format if (token =~ /\A(urn:uuid:)?[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\z/i) == nil puts "\nLE: It appears the LOGENTRIES_TOKEN you entered is invalid!\n" end - end + end end