GithubHelp home page GithubHelp logo

lograge-sql's Introduction

Lograge::Sql

Gem Version CI

Lograge::Sql is an extension to the famous Lograge gem, which adds SQL queries to the Lograge Event and disable default ActiveRecord logging. This is extremely useful if you're using Lograge together with the ELK stack.

Installation

Add this line to your application's Gemfile:

gem 'lograge-sql'

Usage

In order to enable SQL logging in your application, you'll simply need to add this on top of your lograge initializer:

# config/initializers/lograge
require 'lograge/sql/extension'

By default, Lograge::Sql disables default logging on ActiveRecord. To preserve default logging, add this to your lograge initializer:

config.lograge_sql.keep_default_active_record_log = true

Configuration

Minimum query duration threshold

By default, lograge-sql stores all queries, but you can set a min_duration_ms config. When you do so, only queries that run for AT LEAST min_duration_ms milliseconds will be logged, and all others will be ignored. This can be really helpful if you want to detect Slow SQL queries.

# config/initializers/lograge.rb
Rails.application.configure do
  # Defaults is zero
  config.lograge_sql.min_duration_ms = 5000 # milliseconds
end

Output Customization

By default, the format is a string concatenation of the query name, the query duration and the query itself joined by \n newline:

method=GET path=/mypath format=html ...
Object Load (0.42) SELECT "objects.*" FROM "objects"
Associations Load (0.42) SELECT "associations.*" FROM "associations" WHERE "associations"."object_id" = "$1"

However, having Lograge::Formatters::Json.new, the relevant output is

{
    "sql_queries": "name1 ({duration1}) {query1}\nname2 ({duration2}) query2 ...",
    "sql_queries_count": 3
}

To customize the output:

# config/initializers/lograge.rb
Rails.application.configure do

  # Instead of extracting event as Strings, extract as Hash. You can also extract
  # additional fields to add to the formatter
  config.lograge_sql.extract_event = Proc.new do |event|
    { name: event.payload[:name], duration: event.duration.to_f.round(2), sql: event.payload[:sql] }
  end
  # Format the array of extracted events
  config.lograge_sql.formatter = Proc.new do |sql_queries|
    sql_queries
  end
end

Filtering out sensitive info in SQL logs

By default, lograge-sql will log full query but if you have sensitive data that need to be filtered out, you can set query_filter config:

Rails.application.configure do
  config.lograge_sql.query_filter = ->(query) { query.gsub(/custom_regexp/, "[FILTERED]".freeze) }
end

Thread-safety

Depending on the web server in your project you might benefit from improved thread-safety by adding request_store to your Gemfile. It will be automatically picked up by lograge-sql.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/iMacTia/lograge-sql.

lograge-sql's People

Contributors

al-un avatar bolah2009 avatar dependabot[bot] avatar dominh avatar entrity avatar giovannibonetti avatar gkopylov avatar hugopeixoto avatar imactia avatar nhatle-684 avatar olleolleolle avatar petergoldstein avatar rs-phunt avatar silviusimeria avatar takanamito avatar trammel avatar webuilder240 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lograge-sql's Issues

queries executed in rails initializers and queries executed outside of request scope

I've found a minor issue:

In my project, I'm using lograge-sql, and I perform some DB queries in initializers. However, these queries log the error:

Could not log "sql.active_record" event. NoMethodError: undefined method `call' for nil:NilClass ["/home/dominik/.rvm/gems/ruby-2.7.1@dataflow/gems/lograge-sql-1.1.0/lib/lograge/sql/extension.rb:42:in `sql'"

Looking into lograge-sql code, I spotted that lograge-sql is set up in after_initialize hook. So my dirty fix for this was to put the code below in the beginning of initializers:

Lograge::Sql.setup(config.lograge_sql)

This way I surpressed the error. However, SQL queries executed out of a request scope(Rails console, Initializers) are still not logged.

My initial idea to fix it was to move the code below into the setup method, and change it to actually not unsubscribe ActiveRecord::LogSubscriber but decorate it, but I'm not experienced with Lograge code, so I'm not going to develop it now

ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber|
  Lograge.unsubscribe(:active_record, subscriber) if subscriber.is_a?(ActiveRecord::LogSubscriber)
end

Sql Query are not logged and getting an exception

I am getting the following exception when trying to setup lograge-sql

! Unable to load application: NameError: uninitialized constant Lograge::LogSubscribers
 Traceback (most recent call last):
         21: from /usr/local/bundle/gems/ruby/2.5.0/bin/ruby_executable_hooks:24:in `<main>'
         20: from /usr/local/bundle/gems/ruby/2.5.0/bin/ruby_executable_hooks:24:in `eval'
         19: from /usr/local/bundle/gems/ruby/2.5.0/bin/puma:23:in `<main>'
         18: from /usr/local/bundle/gems/ruby/2.5.0/bin/puma:23:in `load'
         17: from /usr/local/bundle/gems/ruby/2.5.0/gems/puma-5.6.4/bin/puma:10:in `<top (required)>'
         16: from /usr/local/bundle/gems/ruby/2.5.0/gems/puma-5.6.4/lib/puma/cli.rb:81:in `run'
         15: from /usr/local/bundle/gems/ruby/2.5.0/gems/puma-5.6.4/lib/puma/launcher.rb:182:in `run'
         14: from /usr/local/bundle/gems/ruby/2.5.0/gems/puma-5.6.4/lib/puma/single.rb:44:in `run'
         13: from /usr/local/bundle/gems/ruby/2.5.0/gems/puma-5.6.4/lib/puma/runner.rb:150:in `load_and_bind'
         12: from /usr/local/bundle/gems/ruby/2.5.0/gems/puma-5.6.4/lib/puma/configuration.rb:270:in `app'
         11: from /usr/local/bundle/gems/ruby/2.5.0/gems/puma-5.6.4/lib/puma/configuration.rb:348:in `load_rackup'
         10: from /usr/local/bundle/gems/ruby/2.5.0/gems/rack-2.2.6.2/lib/rack/builder.rb:66:in `parse_file'
          9: from /usr/local/bundle/gems/ruby/2.5.0/gems/rack-2.2.6.2/lib/rack/builder.rb:105:in `load_file'
          8: from /usr/local/bundle/gems/ruby/2.5.0/gems/rack-2.2.6.2/lib/rack/builder.rb:116:in `new_from_string'
          7: from /usr/local/bundle/gems/ruby/2.5.0/gems/rack-2.2.6.2/lib/rack/builder.rb:116:in `eval'
          6: from config.ru:3:in `block in <main>'
          5: from config.ru:3:in `require'
          4: from /home/app/be/config/environment.rb:2:in `<top (required)>'
          3: from /home/app/be/config/environment.rb:2:in `require_relative'
          2: from /home/app/be/config/application.rb:9:in `<top (required)>'
          1: from /home/app/be/config/application.rb:9:in `require'
 /usr/local/bundle/gems/ruby/2.5.0/gems/lograge-sql-2.1.0/lib/lograge/sql/extension.rb:32:in `<top (required)>': uninitialized constant Lograge::LogSubscribers (NameError)
 uninitialized constant Lograge::LogSubscribers
 /usr/local/bundle/gems/ruby/2.5.0/gems/lograge-sql-2.1.0

My configuration

Gemfile.

gem 'lograge'
gem 'lograge-sql'

Added the below line in my application.rb

require 'rails/all'
require 'lograge/sql/extension'
module Project
  class Application < Rails::Application
  	config.lograge_sql.keep_default_active_record_log = true

    config.lograge.logger = ActiveSupport::Logger.new "#{Rails.root}/log/lograge_#{Rails.env}.log"

    # Add remote IP, client id, hostname, and user id to logs
    config.lograge.custom_options = lambda do |event|
      {
        ip:        event.payload[:ip],
        client_id: event.payload[:client_id],
        hostname:  event.payload[:hostname],
        user_id:   event.payload[:user_id],
        controller: event.payload[:controller],
        action: event.payload[:action],
        params: event.payload[:params],
        exception: event.payload[:exception], 
        exception_object: event.payload[:exception_object]
      }
    end
  end

end

And created the file lograge.rb file inside the initializers folder

Rails.application.configure do

  # Instead of extracting event as Strings, extract as Hash. You can also extract
  # additional fields to add to the formatter
  config.lograge_sql.extract_event = Proc.new do |event|
  	{ name: event.payload[:name], duration: event.duration.to_f.round(2), sql: event.payload[:sql] }
  end
  # Format the array of extracted events
  config.lograge_sql.formatter = Proc.new do |sql_queries|
    sql_queries
  end
end

Also, if I comment on the below line

require 'lograge/sql/extension'

And replace with the below line

require 'lograge/active_record_log_subscriber'

So, the error is not shown but the SQL queries are not logged in the lograge_development.log. Can someone help me with this issue?

Rails - 5.2.8.1
Ruby - 2.5.8

Rails 7.1 deprecation warnings

Just upgraded to Ralis 7.1 on a project and noticed these deprecation warnings:

Beginning of trace:

DEPRECATION WARNING: 
ActiveRecord::LogSubscriber.runtime= is deprecated and will be removed in Rails 7.2.  (called from load at [APP]/vendor/bundle/ruby/3.2.0/bin/rspec:25)
[APP]/vendor/bundle/ruby/3.2.0/gems/lograge-sql-2.3.0/lib/lograge/active_record_log_subscriber.rb:24:in `increase_runtime_duration'
[APP]/vendor/bundle/ruby/3.2.0/gems/lograge-sql-2.3.0/lib/lograge/active_record_log_subscriber.rb:9:in `sql'

Query Runtime is Summed Twice

When config.lograge_sql.keep_default_active_record_log = true, query runtime gets summed twice: once in ActiveRecord::LogSubscriber and again in Lograge::ActiveRecordLogSubscriber.

Lograge failing with Rails 7.0

With the latest update to 2.3.1 it seems like backwards compatibility broke. I'm using Rails 7.0.8 and I'm getting these log entries whenever I'm executing a DB query:

[2023-11-18T00:37:38.143+00:00] ERROR: Could not log "sql.active_record" event. NoMethodError: undefined method `+' for nil:NilClass ["/gems/ruby/3.2.0/gems/lograge-sql-2.3.1/lib/lograge/active_record_log_subscriber.rb:24:
in `increase_runtime_duration'", "/gems/ruby/3.2.0/gems/lograge-sql-2.3.1/lib/lograge/active_record_log_subscriber.rb:9:in `sql'", "/gems/ruby/3.2.0/gems/activesupport-7.0.8/lib/active_support/subscriber.rb:149:in `finish'
", "/gems/ruby/3.2.0/gems/activesupport-7.0.8/lib/active_support/log_subscriber.rb:115:in `finish'", "/gems/ruby/3.2.0/gems/activesupport-7.0.8/lib/active_support/notifications/fanout.rb:211:in `finish'", "/gems/ruby/3.2.0
/gems/activesupport-7.0.8/lib/active_support/notifications/fanout.rb:76:in `block in finish'", "/gems/ruby/3.2.0/gems/activesupport-7.0.8/lib/active_support/notifications/fanout.rb:91:in `block in iterate_guarding_exceptio
ns'", "/gems/ruby/3.2.0/gems/activesupport-7.0.8/lib/active_support/notifications/fanout.rb:90:in `each'", "/gems/ruby/3.2.0/gems/activesupport-7.0.8/lib/active_support/notifications/fanout.rb:90:in `iterate_guarding_excep
tions'", "/gems/ruby/3.2.0/gems/activesupport-7.0.8/lib/active_support/notifications/fanout.rb:76:in `finish'", "/gems/ruby/3.2.0/gems/activesupport-7.0.8/lib/active_support/notifications/instrumenter.rb:49:in `finish_with
_state'", "/gems/ruby/3.2.0/gems/activesupport-7.0.8/lib/active_support/notifications/instrumenter.rb:30:in `instrument'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract_adapter.rb
:743:in `log'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_ada
pters/postgresql_adapter.rb:296:in `initialize'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/postgresql_adapter.rb:36:in `new'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_rec
ord/connection_adapters/postgresql_adapter.rb:36:in `postgresql_connection'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in `public_send'", "/gems/ruby/3
.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in `new_connection'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_p
ool.rb:700:in `checkout_new_connection'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:679:in `try_to_checkout_new_connection'", "/gems/ruby/3.2.0/gems/activer
ecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:640:in `acquire_connection'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:341:in
 `checkout'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `connection'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_adapter
s/abstract/connection_handler.rb:211:in `retrieve_connection'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/connection_handling.rb:313:in `retrieve_connection'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/li
b/active_record/connection_handling.rb:280:in `connection'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/model_schema.rb:407:in `table_exists?'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/
attribute_methods/primary_key.rb:95:in `get_primary_key'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/attribute_methods/primary_key.rb:83:in `reset_primary_key'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/
lib/active_record/attribute_methods/primary_key.rb:71:in `primary_key'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/relation/delegation.rb:93:in `primary_key'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/li
b/active_record/relation/finder_methods.rb:575:in `ordered_relation'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/active_record/relation/finder_methods.rb:174:in `last'", "/gems/ruby/3.2.0/gems/activerecord-7.0.8/lib/ac
tive_record/querying.rb:22:in `last'", "/gems/ruby/3.2.0/gems/railties-7.0.8/lib/rails/commands/runner/runner_command.rb:46:in `<main>'", "/gems/ruby/3.2.0/gems/railties-7.0.8/lib/rails/commands/runner/runner_command.rb:46
:in `eval'", "/gems/ruby/3.2.0/gems/railties-7.0.8/lib/rails/commands/runner/runner_command.rb:46:in `perform'", "/gems/ruby/3.2.0/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'", "/gems/ruby/3.2.0/gems/thor-1.3.0/lib/tho
r/invocation.rb:127:in `invoke_command'", "/gems/ruby/3.2.0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'", "/gems/ruby/3.2.0/gems/railties-7.0.8/lib/rails/command/base.rb:87:in `perform'", "/gems/ruby/3.2.0/gems/railties-
7.0.8/lib/rails/command.rb:48:in `invoke'", "/gems/ruby/3.2.0/gems/railties-7.0.8/lib/rails/commands.rb:18:in `<main>'", "<internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'", "<interna
l:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'", "/gems/ruby/3.2.0/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'", "bin/rails:4:in `<main>'"]
[2023-11-18T00:37:38.145+00:00]

It seems like this commit is responsible.

Rails 5 support

Lograge gem seems to have been updated to v0.5.1 as of May 13, and it seems to work just fine for rails <5.2.

Would you mind if I bump up the dependency versions that lograge-sql would also support rails 5? I would need that in order to upgrade our core project.

Option to separate SQL logs from request log lines

A very beneficial option would be to separate SQL logs on a separate line and specify different log level.

In my specific case I'd like to log SQL queries under DEBUG level, while request logs under INFO level.

Is that feasible given the current code base?

SQL logs appear even in :info level?

I've just replaced logstasher with the lograge/lograge-sql combo and it seems that if I enable lograge-sql, it will show the sql logging when

config.log_level = :info

is set for the environment, which doesn't seem correct.

If I disable the gem, the lograge output is missing the SQL. If I set the level back to :debug, the lograge output has the poorly formatted SQL.

Why isn't SQL no longer displaying?

Hello,

Any ideas why AR SQLs are not showing in logs/test.log?

I've got:

Gemfile

  gem 'lograge'
  gem 'lograge-sql'

config/environments/test.rb

require 'lograge/sql/extension'

Rails.application.configure do
  config.log_level = :debug
  config.lograge.enabled = true
  config.lograge.keep_original_rails_log = true
end

Filtering out sensitive info in SQL logs

I was wondering how we would go about filtering any sensitive information that might be inside our SQL queries when using this gem. We are already using logstop to scrub our logs but it doesn't seem to work on the SQL logs when this gem is being used, as I still see data like email addresses in our SQL logs, which logstop should be scrubbing out.

Lograge v0.11.0 support

Lograge released v0.11.0, which replaces Lograge::RequestLogSubscriber with Lograge::LogSubscribers::ActionController in order to extend some fuctionality support.

This currently breaks this gem's extension here:

class ActiveRecordLogSubscriber < ActiveSupport::LogSubscriber

NoMethodError: undefined method `extract_event' for Lograge::Sql:Module

Could not log "sql.active_record" event. 
NoMethodError: undefined method `extract_event' for Lograge::Sql:Module [".rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/lograge-sql-0.3.0/lib/lograge/sql/extension.rb:28:in `sql'", ".rbenv/versions/2.4.5/lib/ruby/gems/2.4.0/gems/activesupport-5.2.2/lib/active_support/subscriber.rb:101:in `finish'"

uninitialized constant Lograge::ActiveRecordLogSubscriber (NameError)

After upgrading to version 1.3, unfortunately my rails app fails to initialize. Reverting to 1.2 fixes the issue.

I think it's likely to do with #24

The full backtrace is

jonpad@jonpad-laptop ~/git/my-app (master) $ bundle exec rails c
/home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/lograge-sql-1.3.0/lib/lograge/sql.rb:27:in `setup': uninitialized constant Lograge::ActiveRecordLogSubscriber (NameError)
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/lograge-sql-1.3.0/lib/lograge/sql/railtie.rb:14:in `block in <class:Railtie>'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:428:in `instance_exec'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:428:in `block in make_lambda'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:200:in `block (2 levels) in halting'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:605:in `block (2 levels) in default_terminator'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:604:in `catch'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:604:in `block in default_terminator'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:201:in `block in halting'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:513:in `block in invoke_before'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:513:in `each'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:513:in `invoke_before'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:134:in `run_callbacks'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/reloader.rb:88:in `prepare!'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/application/finisher.rb:113:in `block in <module:Finisher>'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:32:in `instance_exec'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:32:in `run'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:61:in `block in run_initializers'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in `each'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in `call'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/initializable.rb:60:in `run_initializers'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/application.rb:363:in `initialize!'
        from /home/jonpad/git/my-app/config/environment.rb:7:in `<main>'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.1/lib/zeitwerk/kernel.rb:33:in `require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:106:in `preload'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
        from -e:1:in `<main>'

Forcing a require of 'lograge-sql' in 'config/environment.rb' changes the backtrace, but it's not a helpful error.

jonpad@jonpad-laptop ~/git/my-app (master) $ bundle exec rails c
/home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- lograge-sql (LoadError)
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.1/lib/zeitwerk/kernel.rb:33:in `require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
        from /home/jonpad/git/my-app/config/environment.rb:4:in `<main>'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.1/lib/zeitwerk/kernel.rb:33:in `require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `block in require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in `load_dependency'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in `require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:106:in `preload'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
        from /home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
        from -e:1:in `<main>'

Adding require: true to the Gemfile for lograge and lograge-sql gives essentially the same error

/home/jonpad/git/rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- lograge-sql (LoadError)

Prevent Default ActiveRecord Logging From Being Disabled

This Gem disables default ActiveRecord logging. Is it possible to configure this behavior such that the default ActiveRecord logging remains enabled?

Reason being is that we currently have our logs going to Stackdriver.

However, I am currently implementing Datadog logging. With the default ActiveRecord logging disabled, the sql queries no longer show up inside of Stackdriver.

As such, I don't want to take away SQL logging from production Stackdriver before Datadog SQL logging is fully configured.

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.