-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log failed queries #326
Log failed queries #326
Conversation
d5ccd08
to
993681e
Compare
src/avram/pool_statement_logging.cr
Outdated
@@ -32,5 +47,13 @@ module DB | |||
Avram.logger.log(level, {query: @query, args: logging_args}) | |||
end | |||
end | |||
|
|||
private def log_error(*args_, args : Array? = nil) | |||
Avram.settings.query_log_level.try do |level| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be log_failed_log_level
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops!
993681e
to
e2f47bd
Compare
@@ -21,6 +21,7 @@ module Avram | |||
setting logger : Dexter::Logger = Dexter::Logger.new(nil) | |||
setting query_log_level : ::Logger::Severity? | |||
setting save_failed_log_level : ::Logger::Severity? = ::Logger::Severity::WARN | |||
setting query_failed_log_level : ::Logger::Severity? = ::Logger::Severity::ERROR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, that makes more sense 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
16d4d5b
to
29a25e9
Compare
29a25e9
to
4962a9a
Compare
Ran into this while working on #322. I wanted to see the failed query.
The downside to this is that if you happen to rescue a
PQ::PQError
later in your app the failed query will still be logged. I think this is acceptable though since I can't think of a reason not to.I've added a setting though just in case you don't want to log failed queries