-
Notifications
You must be signed in to change notification settings - Fork 934
Refactor debug logging in AbstractBatcher #2382
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
Refactor debug logging in AbstractBatcher #2382
Conversation
@@ -93,11 +93,7 @@ private DbCommand Generate(CommandType type, SqlString sqlString, SqlType[] para | |||
} | |||
|
|||
var cmd = _factory.ConnectionProvider.Driver.GenerateCommand(type, sql, parameterTypes); | |||
LogOpenPreparedCommand(); | |||
if (Log.IsDebugEnabled()) |
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.
Moved to LogOpenPreparedCommand
@@ -232,7 +228,7 @@ public int ExecuteNonQuery(DbCommand cmd) | |||
} | |||
finally | |||
{ | |||
if (Log.IsDebugEnabled() && duration != null) |
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.
duration
is created only under Debug logging. I see no point in additional code cluttering with Log.IsDebugEnabled()
} | ||
catch (Exception e) | ||
{ | ||
e.Data["actual-sql-query"] = cmd.CommandText; | ||
Log.Error(e, "Could not execute query: {0}", cmd.CommandText); | ||
throw; | ||
} | ||
finally |
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.
Useless finally block (as in case exception reader
is null). Moved logic to LogOpenReader
Minimize clutter of
Log.IsDebugEnabled
calls and get rid of typing logic inGetReaderStopwatch