Skip to content

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

Merged

Conversation

bahusoid
Copy link
Member

@bahusoid bahusoid commented May 16, 2020

Minimize clutter of Log.IsDebugEnabled calls and get rid of typing logic in GetReaderStopwatch

@@ -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())
Copy link
Member Author

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)
Copy link
Member Author

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
Copy link
Member Author

@bahusoid bahusoid May 16, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants