123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net.Sockets;
- using System.Runtime.CompilerServices;
- using System.Text;
- using SuperSocket.SocketBase;
- namespace SuperSocket.SocketEngine
- {
- abstract partial class SocketSession
- {
- private const string m_GeneralErrorMessage = "Unexpected error";
- private const string m_GeneralSocketErrorMessage = "Unexpected socket error: {0}";
- private const string m_CallerInformation = "Caller: {0}, file path: {1}, line number: {2}";
-
-
-
-
-
-
-
- protected void LogError(Exception exception, [CallerMemberName] string caller = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1)
- {
- int socketErrorCode;
-
- if (IsIgnorableException(exception, out socketErrorCode))
- return;
- var message = socketErrorCode > 0 ? string.Format(m_GeneralSocketErrorMessage, socketErrorCode) : m_GeneralErrorMessage;
- AppSession.Logger.Error(this
- , message + Environment.NewLine + string.Format(m_CallerInformation, caller, callerFilePath, callerLineNumber)
- , exception);
- }
-
-
-
-
-
-
-
-
- protected void LogError(string message, Exception exception, [CallerMemberName] string caller = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1)
- {
- int socketErrorCode;
-
- if (IsIgnorableException(exception, out socketErrorCode))
- return;
- AppSession.Logger.Error(this
- , message + Environment.NewLine + string.Format(m_CallerInformation, caller, callerFilePath, callerLineNumber)
- , exception);
- }
-
-
-
-
-
-
-
- protected void LogError(int socketErrorCode, [CallerMemberName] string caller = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1)
- {
- if (!Config.LogAllSocketException)
- {
-
- if (IsIgnorableSocketError(socketErrorCode))
- return;
- }
- AppSession.Logger.Error(this
- , string.Format(m_GeneralSocketErrorMessage, socketErrorCode) + Environment.NewLine + string.Format(m_CallerInformation, caller, callerFilePath, callerLineNumber)
- , new SocketException(socketErrorCode));
- }
- }
- }
|