fix: improve diagnostics logging and log copy
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.IO;
|
||||
using C4IT.LIAM;
|
||||
using C4IT.Logging;
|
||||
@@ -33,6 +34,7 @@ namespace LiamWorkflowDiagnostics
|
||||
private readonly ObservableCollection<string> _logEntries = new ObservableCollection<string>();
|
||||
private ProviderTestSession _session;
|
||||
private bool _isInitializingUi;
|
||||
private dynamic _diagnosticsLogger;
|
||||
private readonly string _settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "LiamWorkflowDiagnostics.settings.json");
|
||||
|
||||
public MainWindow()
|
||||
@@ -65,7 +67,7 @@ namespace LiamWorkflowDiagnostics
|
||||
var logDirectory = Path.Combine(baseDir, "logs");
|
||||
Directory.CreateDirectory(logDirectory);
|
||||
var logPath = Path.Combine(logDirectory, "LiamWorkflowDiagnostics.log");
|
||||
cLogManagerFile.CreateInstance(logPath);
|
||||
_diagnosticsLogger = cLogManagerFile.CreateInstance(logPath);
|
||||
cLogManager.Instance.Level = LogLevels.Debug;
|
||||
AppendLog($"Logdatei: {logPath} (Level: Debug)");
|
||||
}
|
||||
@@ -137,7 +139,8 @@ namespace LiamWorkflowDiagnostics
|
||||
|
||||
try
|
||||
{
|
||||
cLogManager.DefaultLogger?.LogEntry(level, message);
|
||||
if (_diagnosticsLogger != null)
|
||||
_diagnosticsLogger.LogEntry(level, message);
|
||||
}
|
||||
catch { /* ignore */ }
|
||||
}
|
||||
@@ -227,6 +230,35 @@ namespace LiamWorkflowDiagnostics
|
||||
AppendLog("Log gelöscht.", LogLevels.Debug);
|
||||
}
|
||||
|
||||
private void LogListBox_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.Control)
|
||||
return;
|
||||
|
||||
if (e.Key == Key.A)
|
||||
{
|
||||
LogListBox.SelectAll();
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key != Key.C)
|
||||
return;
|
||||
|
||||
var selectedLines = LogListBox.SelectedItems
|
||||
.Cast<object>()
|
||||
.Select(i => i?.ToString() ?? string.Empty)
|
||||
.Where(i => !string.IsNullOrWhiteSpace(i))
|
||||
.ToList();
|
||||
|
||||
if (selectedLines.Count == 0)
|
||||
return;
|
||||
|
||||
Clipboard.SetText(string.Join(Environment.NewLine, selectedLines));
|
||||
AppendLog($"Logzeilen in Zwischenablage kopiert: {selectedLines.Count}", LogLevels.Debug);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void LoadSettings()
|
||||
{
|
||||
ToolSettings settings = null;
|
||||
|
||||
Reference in New Issue
Block a user