Sha256: 360be3eee27fb1bb561afe1812e6b5d755f9454f1588cb4ad437e419b490dcab

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

require File.join(File.dirname(__FILE__), 'le', 'host')

require 'logger'

module Le

  def self.new(token, options={})

    self.checkParams(token)

    opt_local     = options[:local]     || false
    opt_debug     = options[:debug]     || false
    opt_ssl       = options[:ssl]       || false
    opt_tag       = options[:tag]       || false
    opt_log_level = options[:log_level] || Logger::DEBUG

    host = Le::Host.new(token, opt_local, opt_debug, opt_ssl)

    if defined?(ActiveSupport::TaggedLogging) &&  opt_tag
      logger = ActiveSupport::TaggedLogging.new(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

    logger
  end

  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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
le-2.4.0 lib/le.rb
le-2.3.9 lib/le.rb
le-2.2.9 ./lib/le.rb
le-2.2.8 ./lib/le.rb
le-2.2.6 ./lib/le.rb