// application de couleur void writeToConsole(BattleLogLevel level, String message) { lock (_MessageLock) { String levelStr = Enum.GetName(typeof(BattleLogLevel), level); switch (level) { case BattleLogLevel.EMERGENCY: Console.ForegroundColor = ConsoleColor.Red; break; case BattleLogLevel.ALERT: Console.ForegroundColor = ConsoleColor.Red; break; case BattleLogLevel.CRITICAL: Console.ForegroundColor = ConsoleColor.Red; break; case BattleLogLevel.ERROR: Console.ForegroundColor = ConsoleColor.Red; break; case BattleLogLevel.WARNING: Console.ForegroundColor = ConsoleColor.Yellow; break; case BattleLogLevel.NOTICE: Console.ForegroundColor = ConsoleColor.White; break; case BattleLogLevel.INFO: Console.ForegroundColor = ConsoleColor.Blue; break; case BattleLogLevel.DEBUG: Console.ForegroundColor = ConsoleColor.Magenta; break; default: Console.ForegroundColor = ConsoleColor.White; break; } Console.Write($"[{levelStr}] "); Console.ResetColor(); Console.WriteLine(message); } }
void _log(BattleLogLevel level, String message, object[] list) { String levelStr = Enum.GetName(typeof(BattleLogLevel), level); String dateNow = DateTime.Now.ToString("s"); String content = $"[{levelStr}] [{dateNow}]: {message}"; content += String.Join(',', list); content += '\n'; this.writeToFile(content); logFileS.Flush(); if (this.consoleDisplay) { this.writeToConsole(level, message); } }
void log(BattleLogLevel level, String message, params object[] list) { _log(level, message, list); }