Author: rgrabowski
Date: Sat Jul  9 13:37:45 2005
New Revision: 209963

URL: http://svn.apache.org/viewcvs?rev=209963&view=rev
Log:
Prefixed log message that display sql with the statement id they originated 
from. This allows a logging implementation to apply filters to reduce the 
amount of sql logged. If they use has chosen to use log4net, they can use this 
filter to log sql coming from the User namespace:

 <filter type="log4net.Filter.StringMatchFilter">
  <regExToMatch value="^(?!Statement Id:)|Statement Id: \[User\." />
 </filter>

If the user has maintained a consistent naming scheme (i.e. User.Update, 
User.Insert, Product.Update, Product.Insert) they can create a filter to log 
only Update, Delete, and Insert statements. Sql from Select / GetMany 
statements will not be logged:

 <filter type="log4net.Filter.StringMatchFilter">
  <regExToMatch value="^(?!Statement Id:)|Statement Id: 
\[\w+?\.(?:Update|Insert|Delete)" />
 </filter>

Modified:
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs
    
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs?rev=209963&r1=209962&r2=209963&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs 
(original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Commands/DefaultPreparedCommand.cs 
Sat Jul  9 13:37:45 2005
@@ -73,7 +73,7 @@
 
                        if (_logger.IsDebugEnabled)
                        {
-                               _logger.Debug("PreparedStatement : [" + 
command.CommandText + "]");
+                               _logger.Debug("Statement Id: [" + statement.Id 
+ "] PreparedStatement : [" + command.CommandText + "]");
                        }
 
                        ApplyParameterMap( session, command, request, 
statement, parameterObject  );
@@ -233,8 +233,8 @@
 
                        if (_logger.IsDebugEnabled && properties.Count>0)
                        {
-                               _logger.Debug("Parameters: [" + 
paramLogList.ToString(0, paramLogList.Length - 2)  + "]");
-                               _logger.Debug("Types: [" + 
typeLogList.ToString(0, typeLogList.Length - 2)  + "]");                     
+                               _logger.Debug("Statement Id: [" + statement.Id 
+ "] Parameters: [" + paramLogList.ToString(0, paramLogList.Length - 2)  + "]");
+                               _logger.Debug("Statement Id: [" + statement.Id 
+ "] Types: [" + typeLogList.ToString(0, typeLogList.Length - 2)  + "]");
                        }
                        #endregion 
                }

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs?rev=209963&r1=209962&r2=209963&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.DataMapper/Configuration/Statements/PreparedStatementFactory.cs
 Sat Jul  9 13:37:45 2005
@@ -153,7 +153,7 @@
 
                        if (_logger.IsDebugEnabled) 
                        {
-                               _logger.Debug("SQL for statement '"+ 
_statement.Id +"' :" + _preparedStatement.PreparedSql);
+                               _logger.Debug("Statement Id: [" + _statement.Id 
+ "] Prepared SQL: [" + _preparedStatement.PreparedSql + "]");
                        }
 
                        return _preparedStatement;


Reply via email to