static void UpdateTextBoxOutput(LogMessage message) { try { #if DEBUG message.Message = message.Message + message.Details; #endif List<string> contents = new List<string>(); contents.AddRange(tbOutput.Lines); contents.Add(String.Format("[{0}] {1} > {2} > {3}", message.Timestamp.ToString("HH:mm:ss"), message.GetPriorityString(), message.Category, message.Message)); if (contents.Count <= PruneAT) { tbOutput.Lines = contents.ToArray(); } else { tbOutput.Lines = contents.GetRange(contents.Count - PruneQuantityToKeep, PruneQuantityToKeep).ToArray(); } } catch (Exception _e) { tbOutput = null; LogError("failed to update textbox output within invoke method", "Logger", _e); } }
static void ForwardLogMessage(LogMessage logmessage, string category) { if (ConsoleHandlingMode == ConsoleHandlingOption.SendLoggerOutputToConsole) { string output = String.Format("[{0}] {1} > {2} > {3}{4}", logmessage.Timestamp.ToString("HH:mm:ss"), logmessage.GetPriorityString(), logmessage.Category, logmessage.Message, logmessage.Details); Console.WriteLine(output); } if (LogSavePath != null) { lock (FileSave_lock) { using (StreamWriter fs = new StreamWriter(LogSavePath, true)) { string output = String.Format("[{0}] {1} > {2} > {3}{4}", logmessage.Timestamp.ToString("HH:mm:ss"), logmessage.GetPriorityString(), logmessage.Category, logmessage.Message, logmessage.Details); fs.WriteLine(output); } } } if (CacheForTBOut) { CachedForTBOut.Enqueue(logmessage); } if (tbOutput != null) { SendMessageToTextBoxOutput(logmessage); } }