From: <aye...@us...> - 2009-05-11 13:59:25
|
Revision: 4279 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4279&view=rev Author: ayenderahien Date: 2009-05-11 13:59:15 +0000 (Mon, 11 May 2009) Log Message: ----------- Will now log a warning when getting exception from the database Logging of messages in the SqlClientBatchingBatcher now follow a more consistent approach per logging based on which logger is used Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-05-11 13:43:54 UTC (rev 4278) +++ trunk/nhibernate/src/NHibernate/AdoNet/AbstractBatcher.cs 2009-05-11 13:59:15 UTC (rev 4279) @@ -199,6 +199,7 @@ catch (Exception e) { e.Data["actual-sql-query"] = cmd.CommandText; + log.Warn("Could not execute command: " + cmd.CommandText, e); throw; } } @@ -216,6 +217,7 @@ catch (Exception e) { e.Data["actual-sql-query"] = cmd.CommandText; + log.Warn("Could not exeucte query: " + cmd.CommandText, e); throw; } Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-11 13:43:54 UTC (rev 4278) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-11 13:59:15 UTC (rev 4279) @@ -19,10 +19,7 @@ { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); - if(log.IsDebugEnabled) - { - currentBatchCommandsLog = new StringBuilder(); - } + currentBatchCommandsLog = new StringBuilder(); } public override int BatchSize @@ -35,22 +32,15 @@ { totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - if (log.IsDebugEnabled) + string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); + currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { - string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - { - Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); - } - else - { - log.Debug("Adding to batch:" + lineWithParameters); - } - currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); + Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); } - else + else if (log.IsDebugEnabled) { - Factory.Settings.SqlStatementLogger.LogCommand(batchUpdate, FormatStyle.Basic); + log.Debug("Adding to batch:" + lineWithParameters); } currentBatch.Append((System.Data.SqlClient.SqlCommand) batchUpdate); if (currentBatch.CountOfCommands >= batchSize) @@ -64,14 +54,11 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (log.IsDebugEnabled) - { - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); - else - log.Debug(currentBatchCommandsLog.ToString()); - currentBatchCommandsLog = new StringBuilder(); - } + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); + else if (log.IsDebugEnabled) + log.Debug(currentBatchCommandsLog.ToString()); + currentBatchCommandsLog = new StringBuilder(); int rowsAffected = currentBatch.ExecuteNonQuery(); Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |