Class: BarkestCore::LogViewOptions

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, DateParser
Defined in:
app/models/barkest_core/log_view_options.rb

Constant Summary

Constants included from DateParser

DateParser::DATE_FORMAT, DateParser::NULLABLE_DATE_FORMAT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DateParser

included, parse_for_date_column, parse_for_date_filter, parse_for_time_column, parse_for_time_filter

Instance Attribute Details

#end_timeObject

Returns the value of attribute end_time.



7
8
9
# File 'app/models/barkest_core/log_view_options.rb', line 7

def end_time
  @end_time
end

#max_recordsObject

Returns the value of attribute max_records.



6
7
8
# File 'app/models/barkest_core/log_view_options.rb', line 6

def max_records
  @max_records
end

#searchObject

Returns the value of attribute search.



6
7
8
# File 'app/models/barkest_core/log_view_options.rb', line 6

def search
  @search
end

#start_timeObject

Returns the value of attribute start_time.



7
8
9
# File 'app/models/barkest_core/log_view_options.rb', line 7

def start_time
  @start_time
end

Instance Method Details

#keep_log_entry?(log_entry) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
48
# File 'app/models/barkest_core/log_view_options.rb', line 42

def keep_log_entry?(log_entry)
  return false if min_severity_id && log_entry.level_id < min_severity_id
  return false if start_time && log_entry.time < start_time
  return false if end_time && log_entry.time > (end_time + 1.day)   # include events from the end date.
  return false unless search_regex.nil? || search_regex.match(log_entry.message)
  true
end

#min_severityObject



14
15
16
17
18
# File 'app/models/barkest_core/log_view_options.rb', line 14

def min_severity
  return nil unless instance_variable_defined?(:@min_severity)
  return nil unless @min_severity
  BarkestCore::LogEntry::SEVERITY_LIST[@min_severity]
end

#min_severity=(value) ⇒ Object



10
11
12
# File 'app/models/barkest_core/log_view_options.rb', line 10

def min_severity=(value)
  @min_severity = BarkestCore::LogEntry::SEVERITY_LIST.index(value.to_s.upcase)
end

#min_severity_idObject



20
21
22
23
# File 'app/models/barkest_core/log_view_options.rb', line 20

def min_severity_id
  return nil unless instance_variable_defined?(:@min_severity)
  @min_severity
end

#search_regexObject



33
34
35
36
37
38
39
40
# File 'app/models/barkest_core/log_view_options.rb', line 33

def search_regex
  @search_regex ||=
      if search.blank?
        nil
      else
        /#{search.gsub('[]', '\[\]')}/i rescue nil
      end
end