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
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
- #ignore? ⇒ Boolean
-
#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.
22 23 24 25 26 27 |
# File 'lib/rails_log_parser/action.rb', line 22 def initialize(type, id) self.type = type @id = id @messages = [] @stacktrace = [] end |
Instance Attribute Details
#datetime ⇒ Object
Returns the value of attribute datetime.
20 21 22 |
# File 'lib/rails_log_parser/action.rb', line 20 def datetime @datetime end |
Instance Method Details
#add_message(value) ⇒ Object
61 62 63 64 |
# File 'lib/rails_log_parser/action.rb', line 61 def (value) @messages.push(value) @headline = value if @headline.nil? end |
#add_stacktrace(value) ⇒ Object
66 67 68 |
# File 'lib/rails_log_parser/action.rb', line 66 def add_stacktrace(value) @stacktrace.push(value) end |
#after?(datetime) ⇒ Boolean
57 58 59 |
# File 'lib/rails_log_parser/action.rb', line 57 def after?(datetime) @datetime > datetime end |
#headline ⇒ Object
49 50 51 |
# File 'lib/rails_log_parser/action.rb', line 49 def headline @headline.presence || @messages.first end |
#ignore? ⇒ Boolean
43 44 45 46 47 |
# File 'lib/rails_log_parser/action.rb', line 43 def ignore? @messages.any? do || RailsLogParser.ignore_lines.any? {|ignore| .match?(ignore) } end end |
#known_exception?(key = nil) ⇒ Boolean
37 38 39 40 41 |
# File 'lib/rails_log_parser/action.rb', line 37 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
29 30 31 32 33 34 35 |
# File 'lib/rails_log_parser/action.rb', line 29 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 |