Created
July 4, 2010 12:12
-
-
Save devopsmariocom/463394 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# based on https://rails.lighthouseapp.com/projects/8994/tickets/4807-error-encodingundefinedconversionerror-xc3-from-ascii-8bit-to-utf-8 | |
# invalid multibyte char (UTF-8), ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) | |
diff --git a/activesupport/lib/active_support/buffered_logger.rb b/activesupport/lib/active_support/buffered_logger.rb | |
index 29c3843..5e562ee 100644 | |
--- a/activesupport/lib/active_support/buffered_logger.rb | |
+++ b/activesupport/lib/active_support/buffered_logger.rb | |
@@ -100,7 +100,12 @@ module ActiveSupport | |
def flush | |
@guard.synchronize do | |
unless buffer.empty? | |
- old_buffer = buffer | |
+ if defined? Encoding | |
+ old_buffer = buffer.map { |b| (b.encoding == Encoding::ASCII_8BIT)? b.force_encoding(Encoding::UTF_8).encode : b } | |
+ else | |
+ old_buffer = buffer | |
+ end | |
+ | |
@log.write(old_buffer.join) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment