lib/logdna.rb in logdna-0.0.6 vs lib/logdna.rb in logdna-0.0.7
- old
+ new
@@ -82,9 +82,14 @@
res.flush
end
def push_to_buffer(message, level = nil, source = nil)
app = source || @default_app
+ begin
+ message.encode("UTF-8")
+ rescue Encoding::UndefinedConversionError
+ message = message.force_encoding("UTF-8")
+ end
line = { line: message, app: app, timestamp: Time.now.to_i }
line[:level] = LEVELS[level] if level
start_timer if @buffer.empty?
@buffer << line
return if @buffer.size < @buffer_max