public static void Initialize(LogType logLevel, LogWriter fileLogger = null) { Console.OutputEncoding = Encoding.UTF8; Log.logLevel = logLevel; var logThread = new Thread(() => { while (true) { var log = logQueue.Take(); if (log != null && log.Item2 != null) { if (fileLogger != null) Task.Run(async () => await fileLogger.Write(log.Item2)); Console.ForegroundColor = log.Item1; Console.WriteLine(log.Item2); } } }); logThread.IsBackground = true; logThread.Start(); }
static async Task Initialize(LogWriter fileLogger = null) { await Task.Delay(1).ContinueWith(async _ => { while (true) { var log = logQueue.Take(); if (log != null && fileLogger != null) await fileLogger.Write(log); } }); }
public static async void Initialize(LogType logLevel, LogWriter fileLogger = null) { Log.logLevel = logLevel; await Task.Delay(1).ContinueWith(async _ => { while (true) { var log = logQueue.Take(); if (log != null) { var msg = log.Item2; if (fileLogger != null) await fileLogger.Write(msg); Console.ForegroundColor = log.Item1; Console.WriteLine(msg); } } }); }