using RuriLib.ViewModels;
using System;
using System.Windows.Media;
namespace RuriLib
{
///
/// How critical a log entry is.
///
public enum LogLevel
{
/// An informational message.
Info,
/// A warning message.
Warning,
/// An error message.
Error
}
///
/// A single entry in the log of the application.
///
public class LogEntry : ViewModelBase
{
private string logString = "";
/// The logged message.
public string LogString { get { return logString; } set { logString = value; OnPropertyChanged(); } }
private Color logColor = Colors.White;
/// The color of the logged entry.
public Color LogColor { get { return logColor; } set { logColor = value; OnPropertyChanged(); } }
private DateTime logTime = DateTime.Now;
/// The timestamp of the logged entry.
public DateTime LogTime { get { return logTime; } set { logTime = value; OnPropertyChanged(); } }
private LogLevel logLevel = LogLevel.Info;
/// The level of the logged entry.
public LogLevel LogLevel { get { return logLevel; } set { logLevel = value; OnPropertyChanged(); } }
private string logComponent = "";
/// The component that logged the entry.
public string LogComponent { get { return logComponent; } set { logComponent = value; OnPropertyChanged(); } }
///
/// Creates a Log Entry given a message and a color.
/// This constructor is used to generate entries for the Bot Log.
/// The level is Info and the component is an empty string.
///
/// The message to log
/// The color of the message
public LogEntry(string logString, Color logColor)
{
LogString = logString;
LogColor = logColor;
LogTime = DateTime.Now;
}
///
/// Creates a Log Entry given a component, a message and a level.
/// This constructor is used for logging messages coming from components of the View.
///
/// The Component that is logging the entry
/// The message to log
/// The level of the log
public LogEntry(string logComponent, string logString, LogLevel logLevel)
{
LogString = logString;
LogTime = DateTime.Now;
LogLevel = logLevel;
LogComponent = logComponent;
switch (LogLevel)
{
case LogLevel.Info:
LogColor = Colors.White;
break;
case LogLevel.Warning:
LogColor = Colors.Gold;
break;
case LogLevel.Error:
LogColor = Colors.Tomato;
break;
}
}
}
}