/// <summary> /// Log one packet by calling its PrintPacket method. Only if BONCODEAJP13_LOG_LEVEL >= 1 /// if logAllways is set packet will be logged regardless of log level /// </summary> public void LogPacket(BonCodeAJP13Packet packet, bool logAllways = false, int onlyAboveLogLevel = BonCodeAJP13LogLevels.BONCODEAJP13_NO_LOG) { //only log packets if logging level allows if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL > BonCodeAJP13LogLevels.BONCODEAJP13_NO_LOG && BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL > onlyAboveLogLevel || logAllways) { p_Mut.WaitOne(); using (StreamWriter logStream = File.AppendText(p_FileName)) { if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL == BonCodeAJP13LogLevels.BONCODEAJP13_LOG_HEADERS) { logStream.WriteLine("-- Packet Info:" + packet.ToString() + " at: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString()); logStream.WriteLine(packet.PrintPacketHeader()); logStream.WriteLine(""); logStream.Flush(); logStream.Close(); } ; //logs full packets. Log files may grow big in this case if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL == BonCodeAJP13LogLevels.BONCODEAJP13_LOG_DEBUG) { logStream.WriteLine("-- Packet Info:" + packet.ToString() + " at: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString()); logStream.WriteLine(packet.PrintPacket()); logStream.WriteLine(""); logStream.Flush(); logStream.Close(); } ; } p_Mut.ReleaseMutex(); } }
/// <summary> /// Log one packet by calling its PrintPacket method. Only if BONCODEAJP13_LOG_LEVEL >= 1 /// if logAllways is set packet will be logged regardless of log level. /// Packet logging only occurs if we have exception, Log Headers or Log Debug /// </summary> public void LogPacket(BonCodeAJP13Packet packet, bool logAllways = false, int minLogLevel = BonCodeAJP13LogLevels.BONCODEAJP13_LOG_ERRORS) { //only log packets if logging level allows if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL > BonCodeAJP13LogLevels.BONCODEAJP13_NO_LOG && BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL >= minLogLevel || logAllways) { try { p_Mut.WaitOne(); using (StreamWriter logStream = File.AppendText(p_FileName)) { //log packet headers only if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL == BonCodeAJP13LogLevels.BONCODEAJP13_LOG_HEADERS) { logStream.WriteLine(DateTime.Now.ToString(p_timestampFormat) + packet.ToString() + " " + packet.PrintPacketHeader()); logStream.Flush(); logStream.Close(); } ; //logs full packets. Log files may grow big in this case if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL == BonCodeAJP13LogLevels.BONCODEAJP13_LOG_DEBUG) { logStream.WriteLine(DateTime.Now.ToString(p_timestampFormat) + packet.ToString() + " " + packet.PrintPacketHeader()); logStream.WriteLine(packet.PrintPacket()); logStream.WriteLine(""); logStream.Flush(); logStream.Close(); } ; } p_Mut.ReleaseMutex(); } catch (Exception fileException) { RecordSysEvent("Error during log write : " + fileException.Message, EventLogEntryType.Error); } } }
/// <summary> /// Log one packet by calling its PrintPacket method. Only if BONCODEAJP13_LOG_LEVEL >= 1 /// if logAllways is set packet will be logged regardless of log level. /// Packet logging only occurs if we have exception, Log Headers or Log Debug /// </summary> public void LogPacket(BonCodeAJP13Packet packet, bool logAllways = false, int minLogLevel = BonCodeAJP13LogLevels.BONCODEAJP13_LOG_ERRORS) { //only log packets if logging level allows if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL > BonCodeAJP13LogLevels.BONCODEAJP13_NO_LOG && BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL >= minLogLevel || logAllways) { try { p_Mut.WaitOne(); using (StreamWriter logStream = File.AppendText(p_FileName)) { //log packet headers only if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL == BonCodeAJP13LogLevels.BONCODEAJP13_LOG_HEADERS) { logStream.WriteLine(DateTime.Now.ToString(p_timestampFormat) + packet.ToString() + " " + packet.PrintPacketHeader()); logStream.Flush(); logStream.Close(); } ; //logs full packets. Log files may grow big in this case if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL == BonCodeAJP13LogLevels.BONCODEAJP13_LOG_DEBUG) { logStream.WriteLine(DateTime.Now.ToString(p_timestampFormat) + packet.ToString() + " " + packet.PrintPacketHeader()); logStream.WriteLine(packet.PrintPacket()); logStream.WriteLine(""); logStream.Flush(); logStream.Close(); } ; } p_Mut.ReleaseMutex(); } catch (Exception fileException) { //don't like empty catches but if we cannot log, let's not throw more errors } } }
/// <summary> /// Log one packet by calling its PrintPacket method. Only if BONCODEAJP13_LOG_LEVEL >= 1 /// if logAllways is set packet will be logged regardless of log level /// </summary> public void LogPacket(BonCodeAJP13Packet packet, bool logAllways = false, int onlyAboveLogLevel = BonCodeAJP13LogLevels.BONCODEAJP13_NO_LOG) { //only log packets if logging level allows if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL > BonCodeAJP13LogLevels.BONCODEAJP13_NO_LOG && BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL > onlyAboveLogLevel || logAllways) { p_Mut.WaitOne(); using (StreamWriter logStream = File.AppendText(p_FileName)) { if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL == BonCodeAJP13LogLevels.BONCODEAJP13_LOG_HEADERS) { logStream.WriteLine("-- Packet Info:" + packet.ToString() + " at: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString()); logStream.WriteLine(packet.PrintPacketHeader()); logStream.WriteLine(""); logStream.Flush(); logStream.Close(); }; //logs full packets. Log files may grow big in this case if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL == BonCodeAJP13LogLevels.BONCODEAJP13_LOG_DEBUG) { logStream.WriteLine("-- Packet Info:" + packet.ToString() + " at: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString()); logStream.WriteLine(packet.PrintPacket()); logStream.WriteLine(""); logStream.Flush(); logStream.Close(); }; } p_Mut.ReleaseMutex(); } }
/// <summary> /// Log one packet by calling its PrintPacket method. Only if BONCODEAJP13_LOG_LEVEL >= 1 /// if logAllways is set packet will be logged regardless of log level. /// Packet logging only occurs if we have exception, Log Headers or Log Debug /// </summary> public void LogPacket(BonCodeAJP13Packet packet, bool logAllways = false, int minLogLevel = BonCodeAJP13LogLevels.BONCODEAJP13_LOG_ERRORS) { //only log packets if logging level allows if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL > BonCodeAJP13LogLevels.BONCODEAJP13_NO_LOG && BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL >= minLogLevel || logAllways) { try { p_Mut.WaitOne(); using (StreamWriter logStream = File.AppendText(p_FileName)) { //log packet headers only if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL == BonCodeAJP13LogLevels.BONCODEAJP13_LOG_HEADERS) { logStream.WriteLine(DateTime.Now.ToString(p_timestampFormat) + packet.ToString() + " " + packet.PrintPacketHeader()); logStream.Flush(); logStream.Close(); }; //logs full packets. Log files may grow big in this case if (BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL == BonCodeAJP13LogLevels.BONCODEAJP13_LOG_DEBUG) { logStream.WriteLine(DateTime.Now.ToString(p_timestampFormat) + packet.ToString() + " " + packet.PrintPacketHeader()); logStream.WriteLine(packet.PrintPacket()); logStream.WriteLine(""); logStream.Flush(); logStream.Close(); }; } p_Mut.ReleaseMutex(); } catch (Exception fileException) { //don't like empty catches but if we cannot log, let's not throw more errors } } }