我在JRuby on Rails應用程序中遇到Logger
問題。一個線程將日誌級別更改爲錯誤,並且不會更改。這段代碼是否是線程安全的,還是應該查找它發生的其他地方?這是紅寶石軌道代碼線程安全嗎?
https://github.com/rails/rails/blob/master/activesupport/lib/active_support/benchmarkable.rb#L50
def silence
message = "ActiveSupport::Benchmarkable#silence is deprecated. It will be removed from Rails 4.1."
ActiveSupport::Deprecation.warn message
old_logger_level, logger.level = logger.level, ::Logger::ERROR if logger
yield
ensure
logger.level = old_logger_level if logger
end
感謝您的鏈接,此代碼已過時,但基於此我創建了我的版本。 –