private static string CreateEntry(SocketLogger logger, string text, string prefix) { string retVal = ""; if (text.EndsWith("\r\n")) { text = text.Substring(0, text.Length - 2); } string remIP = "xxx.xxx.xxx.xxx"; try { if (logger.RemoteEndPoint != null) { remIP = (logger.RemoteEndPoint).Address.ToString(); } } catch {} string[] lines = text.Replace("\r\n", "\n").Split('\n'); foreach (string line in lines) { retVal += "SessionID: " + logger.SessionID + " RemIP: " + remIP + " " + prefix + " '" + line + "'\r\n"; } return(retVal); }
/// <summary> /// Converts log entries to string. /// </summary> /// <param name="logger">Socket logger.</param> /// <param name="firstLogPart">Specifies if first log part of multipart log.</param> /// <param name="lastLogPart">Specifies if last log part (logging ended).</param> /// <returns></returns> public static string LogEntriesToString(SocketLogger logger, bool firstLogPart, bool lastLogPart) { string logText = "//----- Sys: 'Session:'" + logger.SessionID + " added " + DateTime.Now + "\r\n"; if (!firstLogPart) { logText = "//----- Sys: 'Session:'" + logger.SessionID + " partial log continues " + DateTime.Now + "\r\n"; } foreach (SocketLogEntry entry in logger.LogEntries) { if (entry.Type == SocketLogEntryType.ReadFromRemoteEP) { logText += CreateEntry(logger, entry.Text, ">>>"); } else if (entry.Type == SocketLogEntryType.SendToRemoteEP) { logText += CreateEntry(logger, entry.Text, "<<<"); } else { logText += CreateEntry(logger, entry.Text, "---"); } } if (lastLogPart) { logText += "//----- Sys: 'Session:'" + logger.SessionID + " removed " + DateTime.Now + "\r\n"; } else { logText += "//----- Sys: 'Session:'" + logger.SessionID + " partial log " + DateTime.Now + "\r\n"; } return(logText); }
private static string CreateEntry(SocketLogger logger, string text, string prefix) { string retVal = ""; if (text.EndsWith("\r\n")) { text = text.Substring(0, text.Length - 2); } string remIP = "xxx.xxx.xxx.xxx"; try { if (logger.RemoteEndPoint != null) { remIP = (logger.RemoteEndPoint).Address.ToString(); } } catch {} string[] lines = text.Replace("\r\n", "\n").Split('\n'); foreach (string line in lines) { retVal += "SessionID: " + logger.SessionID + " RemIP: " + remIP + " " + prefix + " '" + line + "'\r\n"; } return retVal; }
/// <summary> /// Converts log entries to string. /// </summary> /// <param name="logger">Socket logger.</param> /// <param name="firstLogPart">Specifies if first log part of multipart log.</param> /// <param name="lastLogPart">Specifies if last log part (logging ended).</param> /// <returns></returns> public static string LogEntriesToString(SocketLogger logger, bool firstLogPart, bool lastLogPart) { string logText = "//----- Sys: 'Session:'" + logger.SessionID + " added " + DateTime.Now + "\r\n"; if (!firstLogPart) { logText = "//----- Sys: 'Session:'" + logger.SessionID + " partial log continues " + DateTime.Now + "\r\n"; } foreach (SocketLogEntry entry in logger.LogEntries) { if (entry.Type == SocketLogEntryType.ReadFromRemoteEP) { logText += CreateEntry(logger, entry.Text, ">>>"); } else if (entry.Type == SocketLogEntryType.SendToRemoteEP) { logText += CreateEntry(logger, entry.Text, "<<<"); } else { logText += CreateEntry(logger, entry.Text, "---"); } } if (lastLogPart) { logText += "//----- Sys: 'Session:'" + logger.SessionID + " removed " + DateTime.Now + "\r\n"; } else { logText += "//----- Sys: 'Session:'" + logger.SessionID + " partial log " + DateTime.Now + "\r\n"; } return logText; }