Class: RailsLogParser::Action
- Inherits:
-
Object
- Object
- RailsLogParser::Action
- Extended by:
- Enumerize
- Defined in:
- lib/rails_log_parser/action.rb
Constant Summary collapse
- SEVERITIES =
%i[debug info warn error fatal].freeze
- KNOWN_EXCEPTIONS =
{ "Can't verify CSRF token authenticity." => :warn, 'ActionController::InvalidAuthenticityToken' => :fatal, 'ActionController::RoutingError' => :fatal, 'ActionController::UnfilteredParameters' => :fatal, 'ActionController::UnknownFormat' => :fatal, 'ActiveRecord::RecordNotFound' => :fatal, }.freeze
Class Attribute Summary collapse
-
.last ⇒ Object
Returns the value of attribute last.
Instance Attribute Summary collapse
-
#datetime ⇒ Object
Returns the value of attribute datetime.
Instance Method Summary collapse
- #add_message(value) ⇒ Object
- #add_stacktrace(value) ⇒ Object
- #after?(datetime) ⇒ Boolean
- #headline ⇒ Object
-
#initialize(type, id) ⇒ Action
constructor
A new instance of Action.
- #known_exception?(key = nil) ⇒ Boolean
- #severity=(value) ⇒ Object
Constructor Details
#initialize(type, id) ⇒ Action
Returns a new instance of Action.
26 27 28 29 30 31 32 |
# File 'lib/rails_log_parser/action.rb', line 26 def initialize(type, id) self.type = type @id = id @messages = [] @stacktrace = [] self.class.last = self end |
Class Attribute Details
.last ⇒ Object
Returns the value of attribute last.
8 9 10 |
# File 'lib/rails_log_parser/action.rb', line 8 def last @last end |
Instance Attribute Details
#datetime ⇒ Object
Returns the value of attribute datetime.
24 25 26 |
# File 'lib/rails_log_parser/action.rb', line 24 def datetime @datetime end |
Instance Method Details
#add_message(value) ⇒ Object
60 61 62 63 |
# File 'lib/rails_log_parser/action.rb', line 60 def (value) @messages.push(value) @headline = value if @headline.nil? end |
#add_stacktrace(value) ⇒ Object
65 66 67 |
# File 'lib/rails_log_parser/action.rb', line 65 def add_stacktrace(value) @stacktrace.push(value) end |
#after?(datetime) ⇒ Boolean
56 57 58 |
# File 'lib/rails_log_parser/action.rb', line 56 def after?(datetime) @datetime > datetime end |
#headline ⇒ Object
48 49 50 |
# File 'lib/rails_log_parser/action.rb', line 48 def headline @headline.presence || @messages.first end |
#known_exception?(key = nil) ⇒ Boolean
42 43 44 45 46 |
# File 'lib/rails_log_parser/action.rb', line 42 def known_exception?(key = nil) @messages.any? do || KNOWN_EXCEPTIONS.any? { |e, s| .include?(e) && severity == s && (key.nil? || key == e) } end end |
#severity=(value) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/rails_log_parser/action.rb', line 34 def severity=(value) value = value.downcase.to_sym return unless severity.nil? || SEVERITIES.index(severity.to_sym) < SEVERITIES.index(value) super(value) @headline = nil end |