/// <summary> /// write data from the queue to the stream /// </summary> /// <param name="logQueue"></param> /// <param name="writer"></param> private void WriteLog(LogQueue logQueue, TextWriter writer) { try { string []data = logQueue.Dequeue(); if (data.Length > 0) { foreach (string output in data) writer.WriteLine(output); writer.Flush(); } } catch { // do no harm in logging } }
/// <summary> /// generic log writer to handle both information and debug logging /// </summary> /// <param name="debug">flag to determine log type</param> /// <param name="logQueue">the log queue to add to</param> /// <param name="message">developer specified message</param> /// <param name="args">arguments to format in the message parameter</param> private void LogGenetic(bool debug, LogQueue logQueue, string message, params object[] args) { try { string logMessage = string.Format(message, args); if ( debug ) logQueue.Enqueue(); logQueue.Enqueue("{0}{1}{2}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), (debug ? "\r\n" : " "), logMessage); if ( debug ) logQueue.Enqueue(); } catch { // do no harm in logging } }