Class: Logging::Appenders::StackifyRubyLogging

Inherits:
Logging::Appender
  • Object
show all
Defined in:
lib/logging/appenders/stackify.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ StackifyRubyLogging

Returns a new instance of StackifyRubyLogging.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/logging/appenders/stackify.rb', line 11

def initialize(opts = {})
  super(opts[:app_name], opts)
  logger = ::Logger.new(opts[:debug_log])
  version_190 = '1.9.0'
  version_200 = '2.0.0'
  if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new(version_190) ||
    Gem::Version.new(RUBY_VERSION) <= Gem::Version.new(version_200)
    error_msg = 'Error: stackify-ruby-logging gem is currently not compatible in ruby version 1.9.x/2.0.x'
    puts error_msg
    logger.error error_msg
  else
    # Setup the configuration for stackify-api-ruby
    if defined? Stackify
      Stackify.setup do |config|
        config.api_key = opts[:api_key]
        config.env = opts[:environment] || :development
        config.app_name = opts[:app_name] || 'default'
        config.log_level = opts[:log_level] || :debug
        config.mode = :logging
        config.logger = logger
      end
      Stackify.run
    end
  end
end