Actioncable流程的自定义日志记录详细程度

dai*_*no3 5 logging ruby-on-rails actioncable

我有以下Procfile:

web: bundle exec rails s -p $PORT -e $RAILS_ENV Puma
action_cable: bundle exec puma -p $ACTIONCABLE_PORT cable/config.ru
sidekiq: bundle exec sidekiq
Run Code Online (Sandbox Code Playgroud)

无论是action_cable过程和web通过的.bashrc变量出口钢轨过程中使用$ RAILS_ENV变量,设置它的环境轨靴.因此,运行工头开始为两个负载测试环境action_cable和web.但是,我希望actioncable使用:infoLog Level,我希望使用web rails进程fatal.

有没有办法可以启动这两个进程并使用ENV或进程信息来动态设置日志级别?

像(伪代码)的东西:

# environments/test.rb
config.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT))
if Process.port == 28080
  config.log_level = :info
  Sidekiq::Logging.logger.level = Logger::INFO
else
  config.log_level = :fatal
  Sidekiq::Logging.logger.level = Logger::FATAL
end
Run Code Online (Sandbox Code Playgroud)