Refactor #22354
closedMake SilencedLogger thread safe
Description
Rails logger silencer code was thread safe for some time:
https://github.com/rails/rails/commit/629efb605728b31ad9644f6f0acaf3760b641a29
But this has been refactored in Rails 5.0 and thread safety is now part of logger instead of silencer:
https://github.com/rails/rails/commit/2518bda97cbbcb33dc9a92e70d5b01c09e64d12d
The patch made assumption that all Rails applications are using Rails logging stack, but that's not the case for Foreman - we rely on much more flexible "logging" gem (https://github.com/TwP/logging) which does not implement this type of thread safety for levels.
Foreman has its own logging delegator called SilencedLogger and the code there was never thread safe, concurrent sprockets requests are now using silence method which is not thread safe at all, with logging gem this leads to level set to ERROR (the default) after few requests in development mode which renders Foreman unusable (no debug logging output). This patch uses the same technique and stores temporary levels into thread-only context, so on concurrent access there are no incorrect readouts.