826 lines
26 KiB
C#
826 lines
26 KiB
C#
using Eugen.ESystem.Text;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using static Eugen.ESystem.IO.LogWriter;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
|
|
namespace Eugen.ESystem.IO
|
|
{
|
|
public class LogWriter
|
|
{
|
|
#region Version und Copyright
|
|
// Version und Copyright
|
|
static string dllName = System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen
|
|
static string dllVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
|
static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
|
|
static string copyright = GenerateCopyright();
|
|
|
|
//Assembly Datum und Zeit
|
|
static DateTime value = AssemblyDateTime();
|
|
static string date = value.ToShortDateString();
|
|
static string time = value.ToLongTimeString();
|
|
|
|
private static DateTime AssemblyDateTime()
|
|
{
|
|
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
|
var buildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision));
|
|
//Tage seit dem 1. Januar 2000 und Sekunden seit Mitternacht, (multiplizier mit 2 ergibt das Original)
|
|
return buildDateTime;
|
|
}
|
|
|
|
private static string CurrentYear()
|
|
{
|
|
DateTime dtn = DateTime.Now;
|
|
return dtn.Year.ToString();
|
|
}
|
|
|
|
private static string StartYear()
|
|
{
|
|
string startYear = "";
|
|
if (((AssemblyCopyrightAttribute)attributes[0]).Copyright.Contains("Copyright © "))
|
|
{
|
|
startYear = ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace("Copyright © ", "");
|
|
while (startYear.StartsWith(" "))
|
|
{
|
|
startYear = startYear.Remove(0, 1);
|
|
}
|
|
|
|
if (startYear.Contains("-"))
|
|
{
|
|
startYear = startYear.Remove(startYear.IndexOf("-"));
|
|
}
|
|
else
|
|
{
|
|
startYear = startYear.Remove(startYear.IndexOf(" "));
|
|
}
|
|
return startYear;
|
|
}
|
|
else
|
|
{
|
|
DateTime dtn = DateTime.Now;
|
|
return dtn.Year.ToString();
|
|
}
|
|
}
|
|
|
|
private static string GenerateCopyright()
|
|
{
|
|
string startYear = StartYear();
|
|
string currentYear = CurrentYear();
|
|
|
|
if (startYear == currentYear)
|
|
{
|
|
return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
|
|
}
|
|
else
|
|
{
|
|
string temp = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
|
|
string start = temp.Remove(temp.IndexOf(startYear) - 1);
|
|
string end = (temp.Remove(0, temp.IndexOf(" by")));
|
|
|
|
return String.Concat(start, " ", startYear, "-", currentYear, end);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region DLL-Info
|
|
/// <summary>
|
|
/// Contains the name of the dll file.
|
|
/// </summary>
|
|
public static string DllName { private set; get; }
|
|
|
|
/// <summary>
|
|
/// Contains the version of the dll file.
|
|
/// </summary>
|
|
public static string DllVersion { private set; get; }
|
|
|
|
/// <summary>
|
|
/// Contains the copyright notice.
|
|
/// </summary>
|
|
public static string Copyright { private set; get; }
|
|
|
|
/// <summary>
|
|
/// Contains the name-, version- and copyright-information of the dll file.
|
|
/// </summary>
|
|
public static string[] DllInfo { private set; get; }
|
|
|
|
private static void SetDllInfo()
|
|
{
|
|
//Name, Version und Copyright setzen
|
|
DllName = dllName;
|
|
DllVersion = dllVersion;
|
|
Copyright = copyright;
|
|
|
|
string[] dllInfo = new string[3];
|
|
dllInfo[0] = dllName;
|
|
dllInfo[1] = dllVersion;
|
|
dllInfo[2] = copyright;
|
|
DllInfo = dllInfo;
|
|
}
|
|
|
|
protected string ProgramName { private set; get; }
|
|
protected string ProgramVersion { private set; get; }
|
|
protected string ProgramCopyright { private set; get; }
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// Defines whether and what type of header should/should not be generated
|
|
/// </summary>
|
|
public enum Header
|
|
{
|
|
None,
|
|
Default,
|
|
Userdefined
|
|
}
|
|
|
|
/// <summary>
|
|
/// Defines whether the current time should be written or not
|
|
/// </summary>
|
|
public enum Time
|
|
{
|
|
Write,
|
|
NoWrite
|
|
}
|
|
|
|
/// <summary>
|
|
/// Defines whether a logging level should be specified or not
|
|
/// </summary>
|
|
public enum LogLevel
|
|
{
|
|
Debugging,
|
|
Information,
|
|
Warning,
|
|
Error,
|
|
Fatal,
|
|
NoLevel
|
|
}
|
|
|
|
static LogWriter()
|
|
{
|
|
SetDllInfo();
|
|
}
|
|
|
|
public LogWriter(string path)
|
|
{
|
|
SetDllInfo();
|
|
SetDate();
|
|
this.Path = path;
|
|
this.FileName = String.Concat("log_", this.CurrentDate, ".log");
|
|
}
|
|
|
|
public LogWriter(string path, string fileName)
|
|
{
|
|
SetDllInfo();
|
|
SetDate();
|
|
this.Path = path;
|
|
if (fileName.EndsWith(".log"))
|
|
{
|
|
this.FileName = fileName;
|
|
}
|
|
else
|
|
{
|
|
this.FileName = String.Concat(fileName, ".log");
|
|
}
|
|
}
|
|
|
|
private string Path { get; set; }
|
|
private string FileName { get; set; }
|
|
private string CurrentDate { get; set; }
|
|
private string MessageFormat
|
|
{
|
|
get
|
|
{
|
|
return this.messageFormat;
|
|
}
|
|
set
|
|
{
|
|
this.messageFormat = value;
|
|
}
|
|
}
|
|
|
|
private int lineLength = 80;
|
|
private int indentLengthWithoutLogLevel = 15;
|
|
private int indentLengthWithLogLevel = 23;
|
|
|
|
private void SetDate()
|
|
{
|
|
DateTime dateTime = DateTime.Now;
|
|
this.CurrentDate = dateTime.ToString().Remove(dateTime.ToString().IndexOf(" "));
|
|
}
|
|
|
|
private string messageFormat = "{0}{1:T}.{2} - {3}"; // Defines the message format
|
|
|
|
/// <summary>
|
|
/// Name of the program to be logged
|
|
/// </summary>
|
|
public string NameOfProgram { get; set; }
|
|
|
|
/// <summary>
|
|
/// Version number of the program to be logged
|
|
/// </summary>
|
|
public string VersionNumberOfProgram { get; set; }
|
|
|
|
/// <summary>
|
|
/// Copyright of the program to be logged
|
|
/// </summary>
|
|
public string CopyrightOfProgram { get; set; }
|
|
|
|
/// <summary>
|
|
/// Content of a self-defined header as a string
|
|
/// </summary>
|
|
public string UserDefinedHeaderAsString { get; set; }
|
|
|
|
/// <summary>
|
|
/// Content of a self-defined header as a string array
|
|
/// </summary>
|
|
public string[] UserDefinedHeaderAsArray { get; set; }
|
|
|
|
/// <summary>
|
|
/// Writes a separation line to a log file
|
|
/// </summary>
|
|
/// <returns>On success true is returned, on the other hand false</returns>
|
|
public bool WriteSeparationLine()
|
|
{
|
|
string message = String.Empty;
|
|
return WriteMessage(message.PadRight(80, '-'), LogLevel.NoLevel, Time.NoWrite);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Writes a header to a log file
|
|
/// </summary>
|
|
/// <param name="header"></param>
|
|
/// <returns>On success true is returned, on the other hand false</returns>
|
|
public bool WriteHeader(Header header)
|
|
{
|
|
switch (header)
|
|
{
|
|
case Header.Default:
|
|
return WriteDefaultHeader();
|
|
case Header.Userdefined:
|
|
if (!String.IsNullOrEmpty(UserDefinedHeaderAsString))
|
|
{
|
|
return WriteUserDefinedHeader(DefineUserDefinedHeader());
|
|
}
|
|
else if (UserDefinedHeaderAsArray != null)
|
|
{
|
|
return WriteUserDefinedHeader(UserDefinedHeaderAsArray);
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
case Header.None:
|
|
return true;
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
private bool WriteDefaultHeader()
|
|
{
|
|
string message = String.Empty;
|
|
string line = message.PadRight(80, '-');
|
|
|
|
try
|
|
{
|
|
StreamWriter writer;
|
|
|
|
if (!File.Exists(String.Concat(this.Path, "\\", this.FileName)))
|
|
{
|
|
// If log file does not exist yet, create one
|
|
writer = new StreamWriter(String.Concat(this.Path, "\\", this.FileName));
|
|
OnFileCreated(EventArgs.Empty);
|
|
}
|
|
else
|
|
{
|
|
// If log file already exists, then open to write
|
|
writer = new StreamWriter(String.Concat(this.Path, "\\", this.FileName), true);
|
|
}
|
|
|
|
// Write line
|
|
writer.WriteLine(line);
|
|
writer.WriteLine(DefaultHeaderLine1());
|
|
writer.WriteLine(DefaultHeaderLine2());
|
|
writer.WriteLine(DefaultHeaderLine3());
|
|
writer.WriteLine(CurrentDayDateTime());
|
|
writer.WriteLine(line);
|
|
|
|
// Close log file
|
|
writer.Close();
|
|
|
|
OnMessageWritten(new LogWriterEventArgs(LogLevel.NoLevel.ToString(), DateTime.Now, 0, "SUCCESS"));
|
|
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private string DefaultHeaderLine1()
|
|
{
|
|
if (String.IsNullOrEmpty(NameOfProgram))
|
|
{
|
|
return "Program Name:";
|
|
}
|
|
else
|
|
{
|
|
return String.Concat("Program Name: ", NameOfProgram);
|
|
}
|
|
}
|
|
|
|
private string DefaultHeaderLine2()
|
|
{
|
|
if (String.IsNullOrEmpty(VersionNumberOfProgram))
|
|
{
|
|
return "Program Version: ";
|
|
}
|
|
else
|
|
{
|
|
return String.Concat("Program Version: ", VersionNumberOfProgram);
|
|
}
|
|
}
|
|
|
|
private string DefaultHeaderLine3()
|
|
{
|
|
if (String.IsNullOrEmpty(CopyrightOfProgram))
|
|
{
|
|
return "Copyright: ";
|
|
}
|
|
else
|
|
{
|
|
if(CopyrightOfProgram.StartsWith("Copyright"))
|
|
{
|
|
return String.Concat("Copyright: ", CopyrightOfProgram.Remove(0, CopyrightOfProgram.IndexOf(" ") + 1));
|
|
}
|
|
else
|
|
{
|
|
return String.Concat("Copyright: ", CopyrightOfProgram);
|
|
}
|
|
}
|
|
}
|
|
|
|
private string[] DefineUserDefinedHeader()
|
|
{
|
|
if (!String.IsNullOrEmpty(UserDefinedHeaderAsString))
|
|
{
|
|
string[] stringSeparators = new string[] { "\n\r", "\r\n", "\n", "\r" };
|
|
string[] lines = UserDefinedHeaderAsString.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
return lines;
|
|
}
|
|
else
|
|
{
|
|
string[] lines = {" "};
|
|
return lines;
|
|
}
|
|
}
|
|
|
|
private bool WriteUserDefinedHeader(string[] lines)
|
|
{
|
|
string message = String.Empty;
|
|
string line = message.PadRight(80, '-');
|
|
|
|
try
|
|
{
|
|
StreamWriter writer;
|
|
|
|
if (!File.Exists(String.Concat(this.Path, "\\", this.FileName)))
|
|
{
|
|
// If log file does not exist yet, create one
|
|
writer = new StreamWriter(String.Concat(this.Path, "\\", this.FileName));
|
|
OnFileCreated(EventArgs.Empty);
|
|
}
|
|
else
|
|
{
|
|
// If log file already exists, open it for writing
|
|
writer = new StreamWriter(String.Concat(this.Path, "\\", this.FileName), true);
|
|
}
|
|
|
|
// Write lines
|
|
writer.WriteLine(line);
|
|
|
|
for (int i = 0; i < lines.Length; i++)
|
|
{
|
|
writer.WriteLine(lines[i]);
|
|
}
|
|
|
|
writer.WriteLine(line);
|
|
|
|
// Close log file
|
|
writer.Close();
|
|
|
|
OnMessageWritten(new LogWriterEventArgs(LogLevel.NoLevel.ToString(), DateTime.Now, 0, "SUCCESS"));
|
|
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Writes the current day, date and time to a logfile
|
|
/// </summary>
|
|
/// <returns>On success true is returned, on the other hand false</returns>
|
|
public bool WriteDayDateTime()
|
|
{
|
|
try
|
|
{
|
|
StreamWriter writer;
|
|
|
|
if (!File.Exists(String.Concat(this.Path, "\\", this.FileName)))
|
|
{
|
|
// If log file does not exist yet, create one
|
|
writer = new StreamWriter(String.Concat(this.Path, "\\", this.FileName));
|
|
OnFileCreated(EventArgs.Empty);
|
|
}
|
|
else
|
|
{
|
|
// If log file already exists, open it for writing
|
|
writer = new StreamWriter(String.Concat(this.Path, "\\", this.FileName), true);
|
|
}
|
|
|
|
// Write lines
|
|
writer.WriteLine(CurrentDayDateTime());
|
|
|
|
// Close log file
|
|
writer.Close();
|
|
|
|
OnMessageWritten(new LogWriterEventArgs(LogLevel.NoLevel.ToString(), DateTime.Now, 0, "SUCCESS"));
|
|
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private string CurrentDayDateTime()
|
|
{
|
|
DateTime time = DateTime.Now;
|
|
int ms = time.Millisecond;
|
|
|
|
return String.Concat("Date: ", time.DayOfWeek.ToString(), ", ", time, ".", ms.ToString("000"));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Writes a message to a log file
|
|
/// </summary>
|
|
/// <param name="message">The message to write</param>
|
|
/// <returns>On success true is returned, on the other hand false</returns>
|
|
public bool WriteMessage(string message)
|
|
{
|
|
return WriteMessage(message, LogLevel.NoLevel, Time.Write);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Writes a message to a log file
|
|
/// </summary>
|
|
/// <param name="message">The message to write</param>
|
|
/// <param name="writeLogLevel">Writes the log level in front of the line</param>
|
|
/// <param name="writeTime">Writes the log time</param>
|
|
/// <returns>On success true is returned, on the other hand false</returns>
|
|
public bool WriteMessage(string message, LogLevel writeLogLevel, Time writeTime)
|
|
{
|
|
string logLevel = "";
|
|
|
|
switch (writeLogLevel)
|
|
{
|
|
case LogLevel.Debugging:
|
|
logLevel = "DEBUG - ";
|
|
break;
|
|
case LogLevel.Information:
|
|
logLevel = "INFO - ";
|
|
break;
|
|
case LogLevel.Warning:
|
|
logLevel = "WARN - ";
|
|
break;
|
|
case LogLevel.Error:
|
|
logLevel = "ERROR - ";
|
|
break;
|
|
case LogLevel.Fatal:
|
|
logLevel = "FATAL - ";
|
|
break;
|
|
case LogLevel.NoLevel:
|
|
logLevel = "";
|
|
break;
|
|
default:
|
|
logLevel = "";
|
|
break;
|
|
}
|
|
|
|
DateTime time = DateTime.Now;
|
|
int ms = time.Millisecond;
|
|
|
|
if (writeTime == Time.Write)
|
|
{
|
|
return WriteLine(logLevel, time, ms, String.Format(this.messageFormat, new object[] { logLevel, time, ms.ToString("000"), message }));
|
|
}
|
|
else
|
|
{
|
|
return WriteLine(logLevel, time, ms, message);
|
|
}
|
|
}
|
|
|
|
private bool WriteLine(string logLevel, DateTime time, int ms, string message)
|
|
{
|
|
int indentLength = 0;
|
|
|
|
if (logLevel == "")
|
|
{
|
|
indentLength = indentLengthWithoutLogLevel;
|
|
}
|
|
else
|
|
{
|
|
indentLength = indentLengthWithLogLevel;
|
|
}
|
|
|
|
try
|
|
{
|
|
StreamWriter writer;
|
|
|
|
if (!File.Exists(String.Concat(this.Path, "\\", this.FileName)))
|
|
{
|
|
// If the log file does not yet exist, create it
|
|
writer = new StreamWriter(String.Concat(this.Path, "\\", this.FileName));
|
|
OnFileCreated(EventArgs.Empty);
|
|
}
|
|
else
|
|
{
|
|
// If log file already exists, open it for writing
|
|
writer = new StreamWriter(String.Concat(this.Path, "\\", this.FileName), true);
|
|
}
|
|
|
|
// Write line
|
|
if (message.Length > lineLength)
|
|
{
|
|
foreach (string line in FormattingLongStrings.FormattingString(message, lineLength, indentLength, FormattingLongStrings.LengthType.IndentLength))
|
|
{
|
|
writer.WriteLine(line);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
writer.WriteLine(message);
|
|
}
|
|
|
|
// Close log file
|
|
writer.Close();
|
|
|
|
OnMessageWritten(new LogWriterEventArgs(logLevel, time, ms, message));
|
|
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Displays the current logfile
|
|
/// </summary>
|
|
/// <returns>Wheather the displaying progress was successful</returns>
|
|
public bool ShowLogFile()
|
|
{
|
|
return ShowLogFile(this.Path, this.FileName);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Displays a logfile
|
|
/// </summary>
|
|
/// <param name="path">A valid path</param>
|
|
/// <param name="fileName">A valid filename</param>
|
|
/// <returns>Wheather the displaying progress was successful</returns>
|
|
public bool ShowLogFile(string path, string fileName)
|
|
{
|
|
if (String.IsNullOrEmpty(path) || String.IsNullOrEmpty(fileName))
|
|
{
|
|
return false; // Path or name not found
|
|
}
|
|
else
|
|
{
|
|
if (File.Exists(String.Concat(path, "\\", fileName)))
|
|
{
|
|
try
|
|
{
|
|
// Call with the standard program
|
|
var process = new Process();
|
|
process.StartInfo = new ProcessStartInfo()
|
|
{
|
|
UseShellExecute = true,
|
|
FileName = String.Concat(path, "\\", fileName)
|
|
};
|
|
|
|
process.Start();
|
|
process.WaitForExit();
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
try
|
|
{
|
|
const string program = "Notepad.exe"; // Call with Notepad
|
|
|
|
ProcessStartInfo start = new ProcessStartInfo(program, String.Concat(path, "\\", fileName));
|
|
Process.Start(start);
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Deletes the current Logfile
|
|
/// </summary>
|
|
/// <returns>Wheather the deleting progress was successful</returns>
|
|
public bool Delete()
|
|
{
|
|
try
|
|
{
|
|
if (String.IsNullOrEmpty(Path) || String.IsNullOrEmpty(FileName))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (!File.Exists(String.Concat(this.Path, "\\", this.FileName)))
|
|
{
|
|
return true; // No longer exists
|
|
}
|
|
else
|
|
{
|
|
// Muss noch gelöscht werden
|
|
File.Delete(String.Concat(this.Path, "\\", this.FileName));
|
|
|
|
if (File.Exists(String.Concat(this.Path, "\\", this.FileName)))
|
|
{
|
|
return false; // Could not be deleted
|
|
}
|
|
else
|
|
{
|
|
return true; // Successfully deleted
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool Delete(string path, string fileName)
|
|
{
|
|
if (!fileName.EndsWith(".log"))
|
|
{
|
|
fileName = String.Concat(fileName, ".log");
|
|
}
|
|
|
|
try
|
|
{
|
|
if (File.Exists(String.Concat(path, "\\", fileName)))
|
|
{
|
|
File.Delete(String.Concat(path, "\\", fileName));
|
|
|
|
if (File.Exists(String.Concat(path, "\\", fileName)))
|
|
{
|
|
return false; // Could not be deleted
|
|
}
|
|
else
|
|
{
|
|
return true; // Successfully deleted
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return true; // No longer exists
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Provides a method, wich handles events from written messages
|
|
/// </summary>
|
|
/// <param name="sender">Sender object</param>
|
|
/// <param name="e">Event arguments</param>
|
|
public delegate void LogWriterEventHandler(object sender, LogWriterEventArgs e);
|
|
|
|
/// <summary>
|
|
/// Fires the FileCreated event
|
|
/// </summary>
|
|
/// <param name="e">Event arguments</param>
|
|
protected void OnFileCreated(EventArgs e)
|
|
{
|
|
if (FileCreated != null)
|
|
{
|
|
FileCreated(this, e);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fires the MessageWritten event
|
|
/// </summary>
|
|
/// <param name="e">Event arguments</param>
|
|
protected void OnMessageWritten(LogWriterEventArgs e)
|
|
{
|
|
if (MessageWritten != null)
|
|
{
|
|
MessageWritten(this, e);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fired, when a new log file was created. Fired, when a message was written
|
|
/// </summary>
|
|
public event EventHandler FileCreated;
|
|
|
|
/// <summary>
|
|
/// Fired, when a message was written
|
|
/// </summary>
|
|
public event LogWriterEventHandler MessageWritten;
|
|
}
|
|
|
|
/// <summary>
|
|
/// LogWriterEventArgs stores information about the sent log message
|
|
/// </summary>
|
|
public class LogWriterEventArgs : EventArgs
|
|
{
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
/// <param name="time">Specifyes the message post time</param>
|
|
/// <param name="millisecond">Specifyes the message post milliseconds</param>
|
|
/// <param name="message">Specifyes the message</param>
|
|
public LogWriterEventArgs(string logLevel, DateTime time, int millisecond, string message) : base()
|
|
{
|
|
this.logLevel = logLevel;
|
|
this.time = time;
|
|
this.millisecond = millisecond;
|
|
this.message = message;
|
|
}
|
|
|
|
#region fields
|
|
/// <summary>
|
|
/// Stores the logging level
|
|
/// </summary>
|
|
private string logLevel;
|
|
|
|
/// <summary>
|
|
/// Stores the message post time
|
|
/// </summary>
|
|
private DateTime time;
|
|
|
|
/// <summary>
|
|
/// Stores the milliseconds of the post time of the message
|
|
/// </summary>
|
|
private int millisecond;
|
|
|
|
/// <summary>
|
|
/// Stores the message
|
|
/// </summary>
|
|
private string message;
|
|
#endregion
|
|
|
|
#region properties
|
|
/// <summary>
|
|
/// Specifyes the message post time
|
|
/// </summary>
|
|
public DateTime Time
|
|
{
|
|
get
|
|
{
|
|
return this.time;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Specifyes the message
|
|
/// </summary>
|
|
public string Message
|
|
{
|
|
get
|
|
{
|
|
return this.message;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|