Sha256: a3cc9af72a42101d020ecedacab6e601cc1a11fe6511d498914a1830e9e03386
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
require 'date' # Forward all log messages to Elasticsearch. # # Example: # appender = SemanticLogger::Appender::Elasticsearch.new( # url: 'http://localhost:9200' # ) # # # Optional: Exclude health_check log entries # appender.filter = Proc.new { |log| log.message !~ /(health_check|Not logged in)/} # # SemanticLogger.add_appender(appender) # class SemanticLogger::Appender::Elasticsearch < SemanticLogger::Appender::Http attr_accessor :index, :type # Create Elasticsearch appender over persistent HTTP(S) # # Parameters: # index: [String] # Index to store the logs in Elasticsearch. # Default: 'semantic_logger-YYYY.MM.DD' # # type: [String] # Document type to associate with logs when they are written. # Default: 'log' # # level: [:trace | :debug | :info | :warn | :error | :fatal] # Override the log level for this appender. # Default: SemanticLogger.default_level # # 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(options, &block) options = options.dup @index = options.delete(:index) || "semantic_logger-#{Date.today.to_s.gsub('-', '.')}" @type = options.delete(:type) || 'log' options[:url] ||= 'http://localhost:9200' super(options, &block) @request_uri = "#{@index}/#{@type}" end # Deletes all log data captured for this index def delete_all delete(index) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
semantic_logger-3.0.0 | lib/semantic_logger/appender/elasticsearch.rb |