public static void Log(LogType type, [NotNull] string message, [NotNull] params object[] args) { if (message == null) { throw new ArgumentNullException("message"); } if (args == null) { throw new ArgumentNullException("args"); } if (!Enabled) { return; } if (args.Length > 0) { message = String.Format(message, args); } // occasionally \r\n newlines slip into the system, e.g. in stack traces message = message.Replace("\r\n", "\n"); message = Chat.ReplaceNewlines(message); message = Chat.ReplaceEmotesWithUnicode(message); message = Color.StripColors(message); string line = DateTime.Now.ToString(TimeFormat) + " > " + GetPrefix(type) + message; // localized lock ( LogLock ) { RaiseLoggedEvent(message, line, type); RecentMessages.Enqueue(line); while (RecentMessages.Count > MaxRecentMessages) { RecentMessages.Dequeue(); } if (LogFileOptions[(int)type]) { try { File.AppendAllText(Path.Combine(Paths.LogPath, CurrentLogFileName), line + Environment.NewLine); } catch (Exception ex) { string errorMessage = "Logger.Log: " + ex; line = String.Format("{0} > {1}{2}", DateTime.Now.ToString(TimeFormat), // localized GetPrefix(LogType.Error), errorMessage); RaiseLoggedEvent(errorMessage, line, LogType.Error); } } } }