private void WriteMessage(LogLevel logLevel, string message) { var showInPoster = _filter?.Invoke(_name, logLevel, true) ?? false; switch (logLevel) { case LogLevel.Trace: _project.SendInfoToLog($"Trace: {message}", showInPoster); break; case LogLevel.Debug: _project.SendInfoToLog($"Debug: {message}", showInPoster); break; case LogLevel.Info: _project.SendInfoToLog(message, showInPoster); break; case LogLevel.Warning: _project.SendWarningToLog(message, showInPoster); break; case LogLevel.Error: _project.SendErrorToLog(message, showInPoster); break; case LogLevel.Critical: _project.SendErrorToLog(message, showInPoster); break; } }
public void WriteInfo(LogLevel logLevel, object title, object message, bool showInPoster = true) { if (title == null) { title = "▫"; } if (message == null) { message = "▫"; } IZennoPosterProjectModel project = _z.Project; switch (logLevel) { case LogLevel.Normal: project.SendInfoToLog(message.ToString(), title.ToString(), showInPoster); break; case LogLevel.Warning: project.SendWarningToLog(message.ToString(), title.ToString(), showInPoster); break; case LogLevel.Error: project.SendErrorToLog(message.ToString(), title.ToString(), showInPoster); break; default: throw new ArgumentOutOfRangeException(nameof(logLevel), logLevel, nameof(logLevel)); } }
/// <summary> /// Отправка сообщения в лог (ZP/PM или в консоль) /// </summary> /// <param name="msg">сообщение</param> /// <param name="log_type">тип сообщения</param> private static void SendToLog(string msg, LogType log_type = LogType.LogInfo) { if (project != null) { switch (log_type) { case LogType.LogInfo: project.SendInfoToLog(msg, show_in_poster); break; case LogType.LogWarning: project.SendWarningToLog(msg, show_in_poster); break; case LogType.LogError: project.SendErrorToLog(msg, show_in_poster); break; } } else { ConsoleColor previous_bgcolor = Console.BackgroundColor; ConsoleColor previous_fgcolor = Console.ForegroundColor; switch (log_type) { case LogType.LogInfo: Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; break; case LogType.LogWarning: Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Yellow; break; case LogType.LogError: Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Red; break; } Console.WriteLine(msg); Console.BackgroundColor = previous_bgcolor; Console.ForegroundColor = previous_fgcolor; } }
public static IZennoPosterProjectModel Error(this IZennoPosterProjectModel project, string message, bool showInPoster = true) { project.SendErrorToLog(message, showInPoster); return(project); }