fix: improve diagnostics logging and log copy
This commit is contained in:
@@ -479,6 +479,8 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBlock x:Name="StatusTextBlock" Grid.Row="0" Margin="0,0,0,6" Foreground="Gray"/>
|
<TextBlock x:Name="StatusTextBlock" Grid.Row="0" Margin="0,0,0,6" Foreground="Gray"/>
|
||||||
<ListBox x:Name="LogListBox" Grid.Row="1"
|
<ListBox x:Name="LogListBox" Grid.Row="1"
|
||||||
|
SelectionMode="Extended"
|
||||||
|
KeyDown="LogListBox_KeyDown"
|
||||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||||
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
||||||
ScrollViewer.CanContentScroll="True"/>
|
ScrollViewer.CanContentScroll="True"/>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Input;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using C4IT.LIAM;
|
using C4IT.LIAM;
|
||||||
using C4IT.Logging;
|
using C4IT.Logging;
|
||||||
@@ -33,6 +34,7 @@ namespace LiamWorkflowDiagnostics
|
|||||||
private readonly ObservableCollection<string> _logEntries = new ObservableCollection<string>();
|
private readonly ObservableCollection<string> _logEntries = new ObservableCollection<string>();
|
||||||
private ProviderTestSession _session;
|
private ProviderTestSession _session;
|
||||||
private bool _isInitializingUi;
|
private bool _isInitializingUi;
|
||||||
|
private dynamic _diagnosticsLogger;
|
||||||
private readonly string _settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "LiamWorkflowDiagnostics.settings.json");
|
private readonly string _settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "LiamWorkflowDiagnostics.settings.json");
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
@@ -65,7 +67,7 @@ namespace LiamWorkflowDiagnostics
|
|||||||
var logDirectory = Path.Combine(baseDir, "logs");
|
var logDirectory = Path.Combine(baseDir, "logs");
|
||||||
Directory.CreateDirectory(logDirectory);
|
Directory.CreateDirectory(logDirectory);
|
||||||
var logPath = Path.Combine(logDirectory, "LiamWorkflowDiagnostics.log");
|
var logPath = Path.Combine(logDirectory, "LiamWorkflowDiagnostics.log");
|
||||||
cLogManagerFile.CreateInstance(logPath);
|
_diagnosticsLogger = cLogManagerFile.CreateInstance(logPath);
|
||||||
cLogManager.Instance.Level = LogLevels.Debug;
|
cLogManager.Instance.Level = LogLevels.Debug;
|
||||||
AppendLog($"Logdatei: {logPath} (Level: Debug)");
|
AppendLog($"Logdatei: {logPath} (Level: Debug)");
|
||||||
}
|
}
|
||||||
@@ -137,7 +139,8 @@ namespace LiamWorkflowDiagnostics
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cLogManager.DefaultLogger?.LogEntry(level, message);
|
if (_diagnosticsLogger != null)
|
||||||
|
_diagnosticsLogger.LogEntry(level, message);
|
||||||
}
|
}
|
||||||
catch { /* ignore */ }
|
catch { /* ignore */ }
|
||||||
}
|
}
|
||||||
@@ -227,6 +230,35 @@ namespace LiamWorkflowDiagnostics
|
|||||||
AppendLog("Log gelöscht.", LogLevels.Debug);
|
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()
|
private void LoadSettings()
|
||||||
{
|
{
|
||||||
ToolSettings settings = null;
|
ToolSettings settings = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user