lib/semantic_logger/appender/splunk.rb in semantic_logger-2.21.0 vs lib/semantic_logger/appender/splunk.rb in semantic_logger-3.0.0

- old
+ new

@@ -1,14 +1,19 @@ -require 'splunk-sdk-ruby' +begin + require 'splunk-sdk-ruby' +rescue LoadError + raise 'Gem splunk-sdk-ruby is required for logging to Splunk. Please add the gem "splunk-sdk-ruby" to your Gemfile.' +end -# Note: Not recommended to use the colorized formatter. +# Note: This appender is Deprecated. Use: SemanticLogger::Appender::SplunkHttp class SemanticLogger::Appender::Splunk < SemanticLogger::Appender::Base attr_reader :config, :index, :service, :service_index - # Allow the level for this appender to be overwritten - # Default: :error + # DEPRECATED, Please use SemanticLogger::Appender::SplunkHttp def initialize(options, level=:error, &block) + Kernel.warn('Splunk Appender is deprecated, please use SemanticLogger::Appender::SplunkHttp') + # Parse input options for setting up splunk connection parse_options(options) reopen @@ -29,10 +34,10 @@ # Log the message to Splunk def log(log) # Ensure minimum log level is met, and check filter return false if (level_index > (log.level_index || 0)) || !include_message?(log) # Submit the log message - @service_index.submit(formatter.call(log)) + @service_index.submit(formatter.call(log, self)) true end private