rails / solid_queue

Database-backed Active Job backend
MIT License
1.66k stars 90 forks source link

Default Rails logger does not output to STDOUT in development env #238

Closed morgoth closed 1 month ago

morgoth commented 1 month ago

When generating new Rails app (tested with main branch) the deafult Rails logger in development env looks like this:

dupa(dev)> Rails.logger
=> 
#<ActiveSupport::BroadcastLogger:0x00007cad6f8fa608
 @broadcasts=
  [#<ActiveSupport::Logger:0x00007cad6f90da78
    @default_formatter=#<Logger::Formatter:0x00007cad6f8fc9a8 @datetime_format=nil>,
    @formatter=#<ActiveSupport::Logger::SimpleFormatter:0x00007cad6f8fa9c8 @datetime_format=nil>,
    @level=0,
    @level_override={},
    @local_level_key=:logger_thread_safe_level_14520,
    @logdev=
     #<Logger::LogDevice:0x00007cad6f90e748
      @binmode=false,
      @dev=#<File:/home/wojtek/Projects/dupa/log/development.log>,
      @filename="/home/wojtek/Projects/dupa/log/development.log",
      @mon_data=#<Monitor:0x00007cad6f8fc8b8>,
      @mon_data_owner_object_id=4560,
      @shift_age=1,
      @shift_period_suffix="%Y%m%d",
      @shift_size=104857600>,
    @progname=nil>,
   #<ActiveSupport::Logger:0x00007cad6f8506a8
    @default_formatter=#<Logger::Formatter:0x00007cad6f1e4800 @datetime_format=nil>,
    @formatter=#<ActiveSupport::Logger::SimpleFormatter:0x00007cad6f1e4698 @datetime_format=nil>,
    @level=0,
    @level_override={},
    @logdev=
     #<Logger::LogDevice:0x00007cad6f850658
      @binmode=false,
      @dev=#<IO:<STDERR>>,
      @filename=nil,
      @mon_data=#<Monitor:0x00007cad6f1e4760>,
      @mon_data_owner_object_id=14500,
      @shift_age=nil,
      @shift_period_suffix=nil,
      @shift_size=nil>,
    @progname=nil>],
 @formatter=#<ActiveSupport::Logger::SimpleFormatter:0x00007cad6f8fa9c8 @datetime_format=nil>,
 @progname="Broadcast">

When running SQ via bundle exec rake solid_queue:start there is nothing printed on the terminal. SQ logs are only put into the log/development.log file.

I can workaround the issue by specifying logger by hand in environments/development.rb: config.logger = ActiveSupport::Logger.new(STDOUT)

Not sure if this is some issue with Rails or Rails defaults or SQ, but running SQ on fresh new Rails app might be confusing due to no terminal log-feedback when launched.

rosa commented 1 month ago

Hey @morgoth, yes, this is intended, but I'm going to revamp how Solid Queue is used in development, so it runs alongside the rails app process, just like the async adapter, so it shouldn't be confusing for people because they won't need to launch it manually in development.

morgoth commented 1 month ago

Thanks for explanation, closing then.