52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
|
|
using System;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Globalization;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
namespace GenesisZeroFlow
|
|||
|
|
{
|
|||
|
|
public static partial class ErrorLog
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
public static void Log(String reason, String description, String parameter1, String parameter2, CultureInfo culture)
|
|||
|
|
{
|
|||
|
|
#region Definitions and initializations
|
|||
|
|
String userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
|
|||
|
|
String WriteToErrFile = $"{DateTime.Now.ToString(Formats.ErrorLogString, culture)}{userName};{reason};{description};{parameter1};{parameter2}";
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Write settings to file
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (StreamWriter sw0 = File.AppendText(@"..\ErrorLog.txt"))
|
|||
|
|
sw0.WriteLine(WriteToErrFile);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
// MessageBox.Show("Error parameters could not be written to file", "Form closing", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static void Write(String reason, CultureInfo culture)
|
|||
|
|
{
|
|||
|
|
#region Definitions and initializations
|
|||
|
|
String WriteToErrFile = $"{DateTime.Now.ToString("mm:ss:fff", culture)}{reason}";
|
|||
|
|
#endregion
|
|||
|
|
#region Write settings to file
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (StreamWriter sw0 = File.AppendText(@"..\Write.txt"))
|
|||
|
|
sw0.WriteLine(WriteToErrFile);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
// MessageBox.Show("Error parameters could not be written to file", "Form closing", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|