/// <summary> /// Cambia el color de la consola /// </summary> private static void ChangeColor(LogModel.LogType type) { switch (type) { case LogModel.LogType.AssertCorrect: Console.ForegroundColor = ConsoleColor.DarkGray; break; case LogModel.LogType.AssertError: Console.ForegroundColor = ConsoleColor.DarkRed; break; case LogModel.LogType.Debug: Console.ForegroundColor = ConsoleColor.Gray; break; case LogModel.LogType.Error: Console.ForegroundColor = ConsoleColor.Red; break; case LogModel.LogType.Info: Console.ForegroundColor = ConsoleColor.White; break; case LogModel.LogType.Trace: Console.ForegroundColor = ConsoleColor.Green; break; case LogModel.LogType.Warning: Console.ForegroundColor = ConsoleColor.Blue; break; } }
/// <summary> /// Escribe un mensaje /// </summary> private ConsoleColor GetColor(LogModel.LogType type) { switch (type) { case LogModel.LogType.AssertCorrect: return(ConsoleColor.Gray); case LogModel.LogType.AssertError: return(ConsoleColor.Red); case LogModel.LogType.Console: return(ConsoleColor.Black); case LogModel.LogType.Debug: return(ConsoleColor.Gray); case LogModel.LogType.Error: return(ConsoleColor.Red); case LogModel.LogType.Info: return(ConsoleColor.White); case LogModel.LogType.Progress: return(ConsoleColor.White); case LogModel.LogType.Trace: return(ConsoleColor.White); case LogModel.LogType.Warning: return(ConsoleColor.DarkMagenta); default: return(ConsoleColor.White); } }
/// <summary> /// Añade un elemento de log (y lanza el evento) /// </summary> public LogModel Log(BlockLogModel block, LogModel.LogType type, string message, [CallerFilePath] string fileName = null, [CallerMemberName] string methodName = null, [CallerLineNumber] int lineNumber = 0) { // Guarda el log LastLog = new LogModel(GetLastBlock(block), type, message, fileName, methodName, lineNumber); // Devuelve el elemento creado return(LastLog); }
// Public Methods (1) public static void AddMessage(string msg, LogModel.LogType logType) { App.Messenger.NotifyColleagues("DoLog", new LogModel { Message = msg, Type = logType, Time = DateTime.Now.ToLongTimeString() }); }
/// <summary> /// Añade un bloque /// </summary> public BlockLogModel CreateBlock(BlockLogModel parent, LogModel.LogType type, string message, [CallerFilePath] string fileName = null, [CallerMemberName] string methodName = null, [CallerLineNumber] int lineNumber = 0) { BlockLogModel block = new BlockLogModel(Context, GetLastBlock(parent)); // Añade el bloque a la cola Enqueue(block); // Añade el log Log(block, type, message, fileName, methodName, lineNumber); // Devuelve el bloque generado return(block); }
/// <summary> /// Obtiene el color dependiendo del tipo /// </summary> private MvvmColor GetColor(LogModel.LogType type) { switch (type) { case LogModel.LogType.Error: return(MvvmColor.Red); case LogModel.LogType.Warning: return(MvvmColor.Navy); default: return(MvvmColor.Black); } }
/// <summary> /// Añade un elemento de log /// </summary> public LogModel Log(LogModel.LogType type, string message, [CallerFilePath] string fileName = null, [CallerMemberName] string methodName = null, [CallerLineNumber] int lineNumber = 0) { return(Log(null, type, message, fileName, methodName, lineNumber)); }
/// <summary> /// Crea un bloque /// </summary> public BlockLogModel CreateBlock(LogModel.LogType type, string message, [CallerFilePath] string fileName = null, [CallerMemberName] string methodName = null, [CallerLineNumber] int lineNumber = 0) { return(Context.LogItems.CreateBlock(this, type, message, fileName, methodName, lineNumber)); }