lib/semantic_logger/appender/splunk.rb in semantic_logger-4.6.1 vs lib/semantic_logger/appender/splunk.rb in semantic_logger-4.7.0

- old
+ new

@@ -1,9 +1,9 @@ begin - require 'splunk-sdk-ruby' + require "splunk-sdk-ruby" rescue LoadError - raise LoadError.new('Gem splunk-sdk-ruby is required for logging to Splunk. Please add the gem "splunk-sdk-ruby" to your Gemfile.') + raise LoadError, 'Gem splunk-sdk-ruby is required for logging to Splunk. Please add the gem "splunk-sdk-ruby" to your Gemfile.' end # Splunk log appender. # # Use the official splunk gem to log messages to Splunk. @@ -86,11 +86,11 @@ # filter: [Regexp|Proc] # RegExp: Only include log messages where the class name matches the supplied. # regular expression. All other messages will be ignored. # Proc: Only include log messages where the supplied Proc returns true # The Proc must return true or false. - def initialize(index: 'main', source_type: nil, **args, &block) + def initialize(index: "main", source_type: nil, **args, &block) @index = index @source_type = source_type super(**args, &block) reopen @@ -118,18 +118,18 @@ # For splunk format requirements see: # http://dev.splunk.com/view/event-collector/SP-CAAAE6P def call(log, logger) h = SemanticLogger::Formatters::Raw.new.call(log, logger) h.delete(:time) - message = { + message = { source: logger.application, host: logger.host, time: log.time.utc.to_f, message: h.delete(:message), event: h } message[:environment] = logger.environment if logger.environment - message[:sourcetype] = source_type if source_type + message[:sourcetype] = source_type if source_type message end end end end