|
From: <aye...@us...> - 2009-05-15 16:38:55
|
Revision: 4316
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4316&view=rev
Author: ayenderahien
Date: 2009-05-15 16:38:45 +0000 (Fri, 15 May 2009)
Log Message:
-----------
Will push batched command to SQL log as a single unit, or to the batcher log if the sql log is disabled
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs
trunk/nhibernate/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs
trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs
Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-15 08:02:51 UTC (rev 4315)
+++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-15 16:38:45 UTC (rev 4316)
@@ -65,8 +65,13 @@
log.Debug("Executing batch");
CheckReaders();
Prepare(currentBatch.BatchCommand);
- if (log.IsDebugEnabled)
+ if (Factory.Settings.SqlStatementLogger.IsDebugEnabled)
{
+ Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString());
+ currentBatchCommandsLog = new StringBuilder();
+ }
+ else if (log.IsDebugEnabled)
+ {
log.Debug(currentBatchCommandsLog.ToString());
currentBatchCommandsLog = new StringBuilder();
}
Modified: trunk/nhibernate/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs 2009-05-15 08:02:51 UTC (rev 4315)
+++ trunk/nhibernate/src/NHibernate/AdoNet/Util/SqlStatementLogger.cs 2009-05-15 16:38:45 UTC (rev 4316)
@@ -139,5 +139,14 @@
{
return FormatSql ? style : FormatStyle.None;
}
+
+ public void LogBatchCommand(string batchCommand)
+ {
+ log.Debug(batchCommand);
+ if(LogToStdout)
+ {
+ Console.Out.WriteLine("NHibernate: " + batchCommand);
+ }
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs 2009-05-15 08:02:51 UTC (rev 4315)
+++ trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs 2009-05-15 16:38:45 UTC (rev 4316)
@@ -160,6 +160,24 @@
}
[Test]
+ public void SqlLogShouldGetBatchCommandNotification()
+ {
+ using (new LogSpy(typeof(AbstractBatcher)))
+ {
+ using (var sl = new SqlLogSpy())
+ {
+ sessions.Statistics.Clear();
+ FillDb();
+ string logs = sl.GetWholeLog();
+ Assert.That(logs, Text.Contains("Batch command:").IgnoreCase);
+ }
+ }
+
+ Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1));
+ Cleanup();
+ }
+
+ [Test]
[Description(@"Activating the AbstractBatcher's log the log stream:
-should contain well formatted SQL log info")]
public void AbstractBatcherLogFormattedSql()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|