Class: Newshound::ExceptionReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/newshound/exception_reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception_source: nil, configuration: nil, time_range: 24.hours) ⇒ ExceptionReporter

Returns a new instance of ExceptionReporter.



7
8
9
10
11
# File 'lib/newshound/exception_reporter.rb', line 7

def initialize(exception_source: nil, configuration: nil, time_range: 24.hours)
  @exception_source = exception_source || (defined?(ExceptionTrack::Log) ? ExceptionTrack::Log : nil)
  @configuration = configuration || Newshound.configuration
  @time_range = time_range
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



5
6
7
# File 'lib/newshound/exception_reporter.rb', line 5

def configuration
  @configuration
end

#exception_sourceObject (readonly)

Returns the value of attribute exception_source.



5
6
7
# File 'lib/newshound/exception_reporter.rb', line 5

def exception_source
  @exception_source
end

#time_rangeObject (readonly)

Returns the value of attribute time_range.



5
6
7
# File 'lib/newshound/exception_reporter.rb', line 5

def time_range
  @time_range
end

Instance Method Details

#generate_reportObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/newshound/exception_reporter.rb', line 13

def generate_report
  return no_exceptions_block if recent_exceptions.empty?

  [
    {
      type: "section",
      text: {
        type: "mrkdwn",
        text: "*🚨 Recent Exceptions (Last 24 Hours)*"
      }
    },
    *format_exceptions
  ]
end