This project is archived and is in readonly mode.
ruby 1.9 buffered logger -> encoding errors
-
Ivan Ukhov
I have the same problem, when SQL query contains UTF-8 characters, so my patch looks like this:
module ActiveSupport class BufferedLogger def add(severity, message = nil, progname = nil, &block) return if @level > severity message = (message || (block && block.call) || progname).to_s # If a newline is necessary then create a new message ending with a newline. # Ensures that the original message is not mutated. message = "#{message}\n" unless message[-1] == ?\n buffer << message.force_encoding('utf-8') auto_flush message end end end -
majki
I made the same patch in my app. However to make it a bit prettier I used Encoding.default_external instead of hardcoding utf-8
-
majki
- Tag changed from 2.3.6, encoding, ruby19 to 2.3.6, 3.0pre, encoding, ruby19
-
Santiago Pastorino
- State changed from new to open
- Tag changed from 2.3.6, 3.0pre, encoding, ruby19 to 236, 30pre, encoding, ruby19
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale