Browse Source

iSCSI Library: Trace logging is now disabled on Release build

Tal Aloni 8 years ago
parent
commit
23d7003317

+ 2 - 2
ISCSI/ISCSI.Server/ISCSIServer.PDUProcessor.cs

@@ -54,7 +54,7 @@ namespace ISCSI.Server
 
         private void ProcessPDU(ISCSIPDU pdu, ConnectionState state)
         {
-            Log(Severity.Trace, "Entering ProcessPDU");
+            LogTrace("Entering ProcessPDU");
             
             if (state.Session == null || !state.Session.IsFullFeaturePhase)
             {
@@ -192,7 +192,7 @@ namespace ISCSI.Server
                     state.SendQueue.Enqueue(reject);
                 }
             }
-            Log(Severity.Trace, "Leaving ProcessPDU");
+            LogTrace("Leaving ProcessPDU");
         }
 
         private static string FormatNullDelimitedText(string text)

+ 11 - 5
ISCSI/ISCSI.Server/ISCSIServer.cs

@@ -352,7 +352,7 @@ namespace ISCSI.Server
         {
             while (true)
             {
-                Log(Severity.Trace, "Entering ProcessSendQueue");
+                LogTrace("Entering ProcessSendQueue");
                 ISCSIPDU response;
                 bool stopped = !state.SendQueue.TryDequeue(out response);
                 if (stopped)
@@ -380,7 +380,7 @@ namespace ISCSI.Server
                     if (response is LogoutResponsePDU)
                     {
                         clientSocket.Close(); // We can close the connection now
-                        Log(Severity.Trace, "Leaving ProcessSendQueue");
+                        LogTrace("Leaving ProcessSendQueue");
                         return;
                     }
                     else if (response is LoginResponsePDU)
@@ -389,7 +389,7 @@ namespace ISCSI.Server
                         {
                             // Login Response: If the Status Class is not 0, the initiator and target MUST close the TCP connection.
                             clientSocket.Close(); // We can close the connection now
-                            Log(Severity.Trace, "Leaving ProcessSendQueue");
+                            LogTrace("Leaving ProcessSendQueue");
                             return;                            
                         }
                     }
@@ -397,13 +397,13 @@ namespace ISCSI.Server
                 catch (SocketException ex)
                 {
                     Log(Severity.Verbose, "[{0}] Failed to send response to initator. Operation: {1}, Size: {2}, SocketException: {3}", state.ConnectionIdentifier, response.OpCode, response.Length, ex.Message);
-                    Log(Severity.Trace, "Leaving ProcessSendQueue");
+                    LogTrace("Leaving ProcessSendQueue");
                     return;
                 }
                 catch (ObjectDisposedException)
                 {
                     Log(Severity.Verbose, "[{0}] Failed to send response to initator. Operation: {1}, Size: {2}. ObjectDisposedException", state.ConnectionIdentifier, response.OpCode, response.Length);
-                    Log(Severity.Trace, "Leaving ProcessSendQueue");
+                    LogTrace("Leaving ProcessSendQueue");
                     return;
                 }
             }
@@ -423,5 +423,11 @@ namespace ISCSI.Server
         {
             Log(severity, String.Format(message, args));
         }
+
+        [System.Diagnostics.Conditional("TRACE")]
+        public void LogTrace(string message)
+        {
+            Log(Severity.Trace, message);
+        }
     }
 }

+ 1 - 1
ISCSI/ISCSI.csproj

@@ -23,7 +23,7 @@
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
     <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
+    <DefineConstants></DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>