Class: SolidErrors::Frontend::MessageNormalizer
- Inherits:
-
Object
- Object
- SolidErrors::Frontend::MessageNormalizer
- Defined in:
- lib/solid_errors/frontend/message_normalizer.rb
Overview
Collapses the parts of a message that vary between occurrences of the same bug.
Error backends typically fingerprint on the message (Solid Errors hashes exception class + message + severity + source), so an id, a URL or a digest inside the text would split one recurring bug into an unbounded number of groups. Normalising first keeps one bug to one row.
Class Method Summary collapse
Instance Method Summary collapse
- #call(message) ⇒ Object
-
#initialize(filters: SolidErrors::Frontend.message_filters, limit: SolidErrors::Frontend.max_message_length) ⇒ MessageNormalizer
constructor
A new instance of MessageNormalizer.
Constructor Details
#initialize(filters: SolidErrors::Frontend.message_filters, limit: SolidErrors::Frontend.max_message_length) ⇒ MessageNormalizer
Returns a new instance of MessageNormalizer.
15 16 17 18 |
# File 'lib/solid_errors/frontend/message_normalizer.rb', line 15 def initialize(filters: SolidErrors::Frontend., limit: SolidErrors::Frontend.) @filters = filters @limit = limit end |
Class Method Details
.call(message, filters: SolidErrors::Frontend.message_filters, limit: SolidErrors::Frontend.max_message_length) ⇒ Object
11 12 13 |
# File 'lib/solid_errors/frontend/message_normalizer.rb', line 11 def self.call(, filters: SolidErrors::Frontend., limit: SolidErrors::Frontend.) new(filters: filters, limit: limit).call() end |
Instance Method Details
#call(message) ⇒ Object
20 21 22 23 24 |
# File 'lib/solid_errors/frontend/message_normalizer.rb', line 20 def call() text = .to_s.strip.gsub(/\s+/, " ") text = @filters.reduce(text) { |result, (pattern, replacement)| result.gsub(pattern, replacement) } truncate(text) end |