
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
= SQL Logging
{}[https://travis-ci.org/lightyear/sql-logging]
The SQL Logging gem adds useful SQL debugging tools to ActiveRecord. The gem is a repackaging of the old SQL Logging plug-in for Rails 2.x. It, in turn, was based on ideas and plug-ins from Adam Doppelt's (standard logging enhancements) and Nathaniel Talbott (the QueryTrace plug-in).
This gem is for Rails 4+ only. It supports MySQL (including the mysql2 gem), PostgreSQL and SQLite.
== Usage
Once installed, the out-of-the-box behavior gives you:
All of this additional information is logged at DEBUG level, so it won't clutter up your production log files.
== Options
The Top 10 summary provides the most options to customize its behavior.
If you want more or fewer than 10 queries, you can easily change that:
SqlLogging.configuration.top_sql_queries = 5
If you want the sorted by something other than the total execution time, you can instead sort by the median execution time, number of executions or rows/bytes returned over all executions of the query:
SqlLogging.configuration.show_top_sql_queries = :median_time SqlLogging.configuration.show_top_sql_queries = :queries SqlLogging.configuration.show_top_sql_queries = :rows SqlLogging.configuration.show_top_sql_queries = :bytes
You can also turn the list off entirely:
SqlLogging.configuration.show_top_sql_queries = false
If you don't want to see query backtraces:
SqlLogging.configuration.show_sql_backtrace = false
=== General Configuration
In addition to the statistics configuration, more general aspects of the gem can be set through the configuration.
For example, the logger can be set here to store results in alternate location:
SqlLogging.configuration.logger = ActiveSupport::Logger.new(STDOUT)
Additionally, the backtrace cleaner used for generating the call stack can be configured here:
SqlLogging.configuration.backtrace_cleaner.remove_silencers!
= Acknowledgments
Adam's post describing his logging improvements is at http://gurge.com/blog/2006/11/09/rails-sql-logging-improvements/.
Nathaniel's QueryTrace is available at http://terralien.com/projects/querytrace/.
= Contact
Feedback and/or patches to make this gem better are greatly appreciated!
Steve Madsen Light Year Software, LLC http://lightyearsoftware.com steve@lightyearsoftware.com
FAQs
Unknown package
We found that sql-logging demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.