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