diff options
author | schneems <richard.schneeman@gmail.com> | 2016-01-05 16:23:43 -0600 |
---|---|---|
committer | schneems <richard.schneeman@gmail.com> | 2016-01-06 09:55:35 -0600 |
commit | 3d10d9d6c3b831fe9632c43a0ffec46104f912a7 (patch) | |
tree | 0f4e2050c58d477d93e048c71a1cc7c6f3f3f5d2 /activerecord/bin | |
parent | 9dcb1b9b074e313fe0d2a738345c623620f594a2 (diff) | |
download | rails-3d10d9d6c3b831fe9632c43a0ffec46104f912a7.tar.gz rails-3d10d9d6c3b831fe9632c43a0ffec46104f912a7.tar.bz2 rails-3d10d9d6c3b831fe9632c43a0ffec46104f912a7.zip |
[close #22917] Don't output to `STDOUT` twice
When `rails console` or `rails server` are used along with a logger set to output to `STDOUT` then the contents will show up twice. This happens because the logger is extended with `ActiveSupportLogger.broadcast` with a destination of STDOUT even if it is already outputting to `STDOUT`.
Previously PR #22592 attempted to fix this issue, but it ended up causing NoMethodErrors. A better approach than relying on adding a method and flow control is to inspect the log destination directly. For this `ActiveSupport::Logger.logger_outputs_to?` was introduced
```ruby
logger = Logger.new(STDOUT)
ActiveSupport::Logger.logger_outputs_to?(logger, STDOUT)
# => true
```
To accomplish this we must look inside of an instance variable of standard lib's Logger `@logdev`. There is a related Ruby proposal to expose this method in a standard way: https://bugs.ruby-lang.org/issues/11955
Diffstat (limited to 'activerecord/bin')
0 files changed, 0 insertions, 0 deletions