fix: use direct file logging in diagnostics
This commit is contained in:
@@ -34,7 +34,8 @@ namespace LiamWorkflowDiagnostics
|
||||
private readonly ObservableCollection<string> _logEntries = new ObservableCollection<string>();
|
||||
private ProviderTestSession _session;
|
||||
private bool _isInitializingUi;
|
||||
private dynamic _diagnosticsLogger;
|
||||
private readonly object _diagnosticsLogSync = new object();
|
||||
private string _diagnosticsLogPath;
|
||||
private readonly string _settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "LiamWorkflowDiagnostics.settings.json");
|
||||
|
||||
public MainWindow()
|
||||
@@ -66,10 +67,10 @@ namespace LiamWorkflowDiagnostics
|
||||
var baseDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||
var logDirectory = Path.Combine(baseDir, "logs");
|
||||
Directory.CreateDirectory(logDirectory);
|
||||
var logPath = Path.Combine(logDirectory, "LiamWorkflowDiagnostics.log");
|
||||
_diagnosticsLogger = cLogManagerFile.CreateInstance(logPath);
|
||||
_diagnosticsLogPath = Path.Combine(logDirectory, "LiamWorkflowDiagnostics.log");
|
||||
cLogManagerFile.CreateInstance(_diagnosticsLogPath);
|
||||
cLogManager.Instance.Level = LogLevels.Debug;
|
||||
AppendLog($"Logdatei: {logPath} (Level: Debug)");
|
||||
AppendLog($"Logdatei: {_diagnosticsLogPath} (Level: Debug)");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -139,8 +140,14 @@ namespace LiamWorkflowDiagnostics
|
||||
|
||||
try
|
||||
{
|
||||
if (_diagnosticsLogger != null)
|
||||
_diagnosticsLogger.LogEntry(level, message);
|
||||
if (!string.IsNullOrWhiteSpace(_diagnosticsLogPath))
|
||||
{
|
||||
var fileLine = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} [{level}] {message}{Environment.NewLine}";
|
||||
lock (_diagnosticsLogSync)
|
||||
{
|
||||
File.AppendAllText(_diagnosticsLogPath, fileLine, Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { /* ignore */ }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user