You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
3.0 KiB
93 lines
3.0 KiB
using NLog;
|
|
using NLog.Time;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Logging
|
|
{
|
|
public class Logging
|
|
{
|
|
|
|
private static readonly NLog.Logger Logger = NLog.LogManager.GetLogger("EDOKA");
|
|
|
|
public static string connectionstring { get; set; } = "";
|
|
public static string IntLogLevel { get; set; } = "";
|
|
public static string IntUserID { get; set; } = "*";
|
|
|
|
public static void Info(string message, string herkunft, string zusatz)
|
|
{
|
|
if (DoLogging("Info") != true) { return; }
|
|
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
|
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
|
Logger.Info(message);
|
|
}
|
|
public static void Warning(string message, string herkunft, string zusatz)
|
|
{
|
|
if (DoLogging("Warning") != true) { return; }
|
|
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
|
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
|
Logger.Warn(message);
|
|
}
|
|
public static void Error(string message, string herkunft, string zusatz) {
|
|
if (DoLogging("Error") != true) { return; }
|
|
|
|
GlobalDiagnosticsContext.Set("Herkunft",herkunft);
|
|
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
|
Logger.Error(message);
|
|
}
|
|
|
|
public static void Fatal(string message, string herkunft, string zusatz)
|
|
{
|
|
if (DoLogging("Fatal") != true) { return; }
|
|
|
|
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
|
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
|
Logger.Fatal(message);
|
|
}
|
|
public static void Trance(string message, string herkunft, string zusatz)
|
|
{
|
|
if (DoLogging("Trace") != true) { return; }
|
|
|
|
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
|
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
|
Logger.Trace(message);
|
|
}
|
|
public static void Debug(string message, string herkunft, string zusatz)
|
|
{
|
|
if (DoLogging("Debug") != true) { return; }
|
|
|
|
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
|
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
|
Logger.Debug(message);
|
|
}
|
|
|
|
|
|
|
|
private static Boolean DoLogging(string Loglevel)
|
|
{
|
|
if (IntUserID != "*")
|
|
{
|
|
if (IntUserID.Contains(System.Security.Principal.WindowsIdentity.GetCurrent().Name))
|
|
{
|
|
if (IntLogLevel.Contains(Loglevel))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (IntLogLevel.Contains(Loglevel))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|