private void FormatMessage(GRYLogConfiguration configuration, string message, DateTime momentOfLogEntry, LogLevel loglevel, GRYLogLogFormat format, out string formattedMessage, out int colorBegin, out int colorEnd, out ConsoleColor consoleColor, string messageIdValue) { consoleColor = configuration.GetLoggedMessageTypesConfigurationByLogLevel(loglevel).ConsoleColor; if (!string.IsNullOrEmpty(configuration.Name)) { message = $"[{configuration.Name.Trim()}] {message}"; } if (configuration.ConvertTimeForLogentriesToUTCFormat) { momentOfLogEntry = momentOfLogEntry.ToUniversalTime(); } switch (format) { case GRYLogLogFormat.OnlyMessage: formattedMessage = message; colorBegin = 0; colorEnd = 0; break; case GRYLogLogFormat.GRYLogFormat: string messageId; if (string.IsNullOrWhiteSpace(messageIdValue)) { messageId = string.Empty; } else { messageId = $"[{messageIdValue}] "; } string part1 = $"[{momentOfLogEntry.ToString(configuration.DateFormat)}] {messageId}["; string part2 = configuration.GetLoggedMessageTypesConfigurationByLogLevel(loglevel).CustomText; string part3 = "] " + message; formattedMessage = part1 + part2 + part3; colorBegin = part1.Length; colorEnd = part1.Length + part2.Length; break; case GRYLogLogFormat.DateOnly: formattedMessage = momentOfLogEntry.ToString(configuration.DateFormat) + " " + message; colorBegin = 0; colorEnd = 0; break; default: throw new KeyNotFoundException($"Formatting {nameof(GRYLogLogFormat)} '{loglevel}' is not implemented yet."); } }