private static void ProcessConsoleLogItem() { foreach (var item in ConsoleLogQueue.GetConsumingEnumerable()) { Object thing = item.Item1; Nullable <ConsoleColor> color = item.Item2; LogVerbosity verbosity = item.Item3; bool writeLine = item.Item4; if (color != null && color.HasValue) { WriteToConsoleLog(thing, color.Value, verbosity, writeLine); } else { if (thing is Object[]) { WriteToConsoleLog(thing as object[], verbosity); } else { WriteToConsoleLog(thing, verbosity, writeLine); } } } }
public static void StopConsoleLogThread() { ConsoleLogQueue.CompleteAdding(); ConsoleLoggingThread.Join(500); ConsoleLoggingThread.Abort(); _consoleLogEnabled = false; }
private static void AddToConsoleLogQueue(Object thing, Nullable <ConsoleColor> color = null, LogVerbosity verbosity = LogVerbosity.Normal, bool writeLine = true) { if (_consoleLogEnabled && ShouldDisplay(verbosity)) { ConsoleLogQueue.Add(new Tuple <object, Nullable <ConsoleColor>, LogVerbosity, bool>(thing, color, verbosity, writeLine)); } }
public void LogConsole(string message) { if (bLogConsole) { ConsoleLogQueue.Enqueue(message); Console.Write(message); } }
public void WaitForLoggingCompletion() { while (ConsoleLogQueue.Any() || ErrorLogQueue.Any() || FailedEndpointsLogQueue.Any() || ResponseLogQueue.Any() || PerformanceLogQueue.Any()) { Thread.Sleep(10); } WriteAllLogs(); }