Class: Loggie::Logentries::Search

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/loggie/logentries/search.rb

Overview

Main entry point to query a specific log source

Constant Summary collapse

BASE_URI =
"https://rest.logentries.com"
QUERY_PATH =
"query/logs"

Instance Method Summary collapse

Methods included from Logging

included, logger, #logger, logger=

Constructor Details

#initialize(query: nil, from: nil, to: nil, log_files: nil, block: nil) ⇒ Search

Returns a new instance of Search.

Parameters:

  • query: (String) (defaults to: nil)

    to perform

  • from: (DateTime) (defaults to: nil)

    query from date

  • to: (DateTime) (defaults to: nil)

    query to date

  • log_files: (Array) (defaults to: nil)

    list of log id files to search. default ENV



15
16
17
18
19
20
# File 'lib/loggie/logentries/search.rb', line 15

def initialize(query: nil, from: nil, to: nil, log_files: nil, block: nil)
  @query, @from, @to = query, from, to
  @log_files = log_files || Loggie.configuration.log_files
  @extract = Extract.new
  @request = Request.new(retry_mechanism: Retry.new(block: block))
end

Instance Method Details

#call(query: nil, from: nil, to: nil, log_files: nil) ⇒ Object



22
23
24
25
26
27
# File 'lib/loggie/logentries/search.rb', line 22

def call(query: nil, from: nil, to: nil, log_files: nil)
  options = parsed_post_params(query || @query, from || @from, to || @to, log_files || @log_files)
  logger.debug "#{self.class} options:#{options}, url:#{url}"

  extract.call(request.call(url, method: :post, options: options))
end