Avoid repeated NTFS engine logger initialization
This commit is contained in:
@@ -17,6 +17,7 @@ using C4IT.Logging;
|
||||
|
||||
using static C4IT.Logging.cLogManager;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using C4IT_IAM_GET;
|
||||
using C4IT.LIAM;
|
||||
|
||||
@@ -75,18 +76,33 @@ namespace C4IT_IAM_SET
|
||||
public List<IAM_SecurityGroupTemplate> templates;
|
||||
|
||||
public int createTraverseGroupLvl = 0;
|
||||
private static int engineFileLoggerInitialized;
|
||||
|
||||
public DataArea_FileSystem()
|
||||
{
|
||||
EnsureEngineFileLoggerInitialized();
|
||||
|
||||
if (DefaultLogger != null)
|
||||
{
|
||||
DefaultLogger.LogEntry(LogLevels.Info, "=================================================");
|
||||
DefaultLogger.LogEntry(LogLevels.Info, $"LIAM engine v{Assembly.GetExecutingAssembly().GetName().Version} started");
|
||||
}
|
||||
|
||||
templates = new List<IAM_SecurityGroupTemplate>();
|
||||
}
|
||||
|
||||
private static void EnsureEngineFileLoggerInitialized()
|
||||
{
|
||||
if (DefaultLogger != null)
|
||||
return;
|
||||
|
||||
if (Interlocked.Exchange(ref engineFileLoggerInitialized, 1) != 0)
|
||||
return;
|
||||
|
||||
var logDirectory = Environment.ExpandEnvironmentVariables(constApplicationDataPath);
|
||||
Helper.CreatePathWithWriteAccess(logDirectory);
|
||||
var LogPath = Path.Combine(logDirectory, "Logs");
|
||||
cLogManagerFile.CreateInstance(Path.Combine(LogPath, "LIAM.log"));
|
||||
|
||||
DefaultLogger.LogEntry(LogLevels.Info, "=================================================");
|
||||
DefaultLogger.LogEntry(LogLevels.Info, $"LIAM engine v{Assembly.GetExecutingAssembly().GetName().Version} started");
|
||||
|
||||
templates = new List<IAM_SecurityGroupTemplate>();
|
||||
}
|
||||
|
||||
private string GetAdServer()
|
||||
|
||||
Reference in New Issue
Block a user