class Loga::Event
Attributes
data[RW]
exception[RW]
message[RW]
timestamp[RW]
type[RW]
Public Class Methods
new(opts = {})
click to toggle source
# File lib/loga/event.rb, line 5 def initialize(opts = {}) @data = opts[:data] @exception = opts[:exception] @message = safe_encode(opts[:message]) @timestamp = opts[:timestamp] @type = opts[:type] end
Private Instance Methods
safe_encode(text)
click to toggle source
Guard against Encoding::UndefinedConversionError stackoverflow.com/questions/13003287/encodingundefinedconversionerror
# File lib/loga/event.rb, line 17 def safe_encode(text) text.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') end