Missing logs with Puma
After adding this gem, the development environment using Puma server miss all logs. (There is only logs for the first request)
Thank you.
:+1: same here ... second request stops logging :<
@route
Like I said in a previous thread I use it myself, no probs. Give me reproducible app and I'll work it out
only happens in apps with lots of assets on multithreaded puma
solution is making rails logger level thread safe ...
inspired by http://log.kares.org/2011/04/railslogger-is-not-threadsafe.html
ActiveSupport::Logger.class_eval do
def level
Thread.current[thread_hash_level_key] || @level
end
def level=(level)
Thread.current[thread_hash_level_key] = level
end
private
def thread_hash_level_key
@thread_hash_level_key ||= :"ActiveSupport::Logger:#{object_id}"
end
end
a better solution would be for puma to use a new logger for each thread ... or rails doing that ...
tried adding
Rails.logger = Rails.logger.dup to pumas on_worker_boot ... but the puma config is not loaded when doing rails s so that's not helpful ...
with this patch the rails log stops disappearing ... but now I see that quiet assets did not actually work / it still shows assets ... maybe I'll play more with this later ...
I'd caught in this issue while was tried to move to puma server. Wasted a couple hours trying to synchronize a reset of log level, however the best I could do is to fix a level resetting in the ensure clause to Rails.application.config.log_level There is the fork: https://github.com/tinbka/quiet_assets
seems this is still a problem? hard to use puma if logging is not working.
@emiltin, I've ended up implementing this feature in my own logger. See https://github.com/tinbka/tracee