Commit Graph

9 Commits

Author SHA1 Message Date
Xavier Noria a731125f12 applies new string literal convention in activesupport/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:10:53 +02:00
Rafael Mendonça França 1de3db9046
Make sure the yielded variable is the logger 2016-06-10 13:30:50 -04:00
Kevin McPhillips 83f9cdb02a Be explicit about what Logger class is expected 2016-06-09 22:11:07 -04:00
Piotr Jakubowski 2518bda97c Fix logger silencing for broadcasted loggers
Fix #23609

Commit 629efb6 introduced thread safety to logger silencing but it
didn't take into account the fact that the logger can be extended with
broadcasting to other logger.

This commit introduces local_level to broadcasting Module which enables
broadcasted loggers to be properly silenced.
2016-02-11 21:00:51 +01:00
schneems 3d10d9d6c3 [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
2016-01-06 09:55:35 -06:00
Carl P. Corliss 629efb6057 Fixes LoggerSilence#silence threadsafety
- uses instance defined level if no custom local log level defined
- Keeps track of local log level per [ thread + object-instance ]
- prevents memory leakage by removing local level hash key/value on #silence method exit
- avoids the use of Thread local variables
2015-12-23 12:57:33 -05:00
David Heinemeier Hansson f914454f3a Add ActiveSupport::Logger#silence that works the same as the old Logger#silence extension 2012-12-21 19:15:36 +01:00
Arun Agrawal 27a8e693da no more deprecation required. 2012-03-31 23:00:13 +05:30
Arun Agrawal 6a240826ca No more BufferedLogger so it can be LoggerTest 2012-03-31 22:49:15 +05:30
Renamed from activesupport/test/buffered_logger_test.rb (Browse further)