Giter Club home page Giter Club logo

Comments (6)

bensheldon avatar bensheldon commented on June 3, 2024 3

@morgoth whoops, you're correct about ActiveRecord::Base.verbose_query_logs = false. I was thinking that controlled the entirety of the SQL query logging, but it seems like the query logging is simply a :debug-level log.

Thinking more about it, it does straddle the line of Rails configuration and GoodJob. Query logging is an implicit feature of Rails and the Rails logger... and GoodJob is unexpectedly verbose just given that it has to poll on a regular basis.

Your workaround is similar to what I have in my Rails projects:

# config/environments/{development.rb|production.rb}
config.log_level = ENV.fetch("RAILS_LOGGER_LEVEL", "info")

I'll transform this Issue into a feature request for a constant for checking whether configuration is running as part of GoodJob.

# config/initializers/good_job.rb
if GoodJob.within_cli?
  Rails.application.config.log_level = ENV.fetch("RAILS_LOGGER_LEVEL", "info")
end

from good_job.

bensheldon avatar bensheldon commented on June 3, 2024

I think you’re experiencing Rails’s verbose query logging: https://guides.rubyonrails.org/debugging_rails_applications.html#verbose-query-logs

Verbose query logs are turned on by default in development, and (I think) off in production.

I agree, it’s annoying; it also shows up when running in async execution mode too.

There are a couple different approaches one could take:

  • Change the log level so DEBUG-level logs are outputted, as you described.

  • Changing ActiveRecord::Base.verbose_query_logs = false.

  • Making it easier to do either one of those options in configuration when using the $ good_job CLI. e,.g.

    # config/initializers/good_job.rb
    if GoodJob.within_cli? # not a method that currently exists
      ActiveRecord::Base.verbose_query_logs = false
    end
  • You can also dial back the poll-interval to something like 1 minute, which would decrease the frequency of the logs.

from good_job.

morgoth avatar morgoth commented on June 3, 2024

As it goes for ActiveRecord::Base.verbose_query_logs = false, it won't tweak this as this config prints the caller of given SQL statement https://github.com/rails/rails/blob/ab4ab090667e96c0e8a2623e33573ae06be14b54/guides/source/debugging_rails_applications.md#verbose-query-logs

I guess having something like GoodJob.within_cli? would be helpful

from good_job.

minimul avatar minimul commented on June 3, 2024

As mentioned above you can also raise the polling duration to keep the dev log from getting huge: e.g. 1 minute.

GOOD_JOB_POLL_INTERVAL=60 bundle exec good_job start

@bensheldon states that polling can be shut off by setting the interval to -1 but I could not get that to stick, tried:

GOOD_JOB_POLL_INTERVAL=-1
GOOD_JOB_POLL_INTERVAL="-1"

from good_job.

bensheldon avatar bensheldon commented on June 3, 2024

@minimul Thanks for the assist and for flagging that problem! I've opened up an Issue #133 to investigate.

from good_job.

bensheldon avatar bensheldon commented on June 3, 2024

Revisiting this, there is a method to test whether the current process is running as part of the $ good_job executable:

GoodJob::CLI.within_exe?

from good_job.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.