public static void WriteEntry(string line, object sender) { String fullEntry = string.Empty; if (isTimestamped) { fullEntry = "[" + DateTime.Now.ToString() + "]: "; } fullEntry += line + Environment.NewLine; if (isLogFileWritten) { LogCue.Enqueue(fullEntry); } ReportDataRecieved(fullEntry, sender); }
private static void LogWriteOut() { if (LogCue.Count > 0) { using (var logStream = File.Open(logFilePath, FileMode.Append)) { while (LogCue.Count > 0) { string entry; if (LogCue.TryDequeue(out entry)) { logStream.Write(Encoding.UTF8.GetBytes(entry), 0, entry.Length); } } } } }