Add log auto-clear setting (retention in days, 0 = off)
Neue Einstellung "Protokoll auto-leeren - Eintraege aelter als (Tage)". 0 = aus (alle Eintraege bleiben), >0 entfernt aeltere Eintraege. - UserSettings.LogRetentionDays (Standard 0). - Logger.PruneOlderThan(days): parst den Zeitstempel-Prefix je Zeile und entfernt zu alte; Zeilen ohne Zeitstempel bleiben erhalten. - Ausgefuehrt beim Start, vor jedem Sync (Coordinator), beim Oeffnen des Protokolls und beim Speichern der Einstellungen. - SettingsForm: NumericUpDown (0-3650). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using StarfaceOutlookSync.Models;
|
||||
using StarfaceOutlookSync.Services;
|
||||
|
||||
namespace StarfaceOutlookSync.UI
|
||||
{
|
||||
@@ -8,6 +9,7 @@ namespace StarfaceOutlookSync.UI
|
||||
{
|
||||
private CheckBox _chkStartMinimized, _chkSyncOnStart, _chkAutoAcceptOutlook;
|
||||
private CheckBox _chkNotifGeneral, _chkNotifWarn;
|
||||
private NumericUpDown _numLogRetention;
|
||||
private TextBox _txtSharedDir;
|
||||
private Button _btnBrowseShared;
|
||||
private Button _btnSave, _btnCancel;
|
||||
@@ -76,21 +78,33 @@ namespace StarfaceOutlookSync.UI
|
||||
Checked = _settings.NotifyWarningsErrors
|
||||
};
|
||||
|
||||
var lblLogRetention = new Label
|
||||
{
|
||||
Text = "Protokoll auto-leeren - Eintraege aelter als (Tage, 0 = aus):",
|
||||
Left = 20, Top = 204, AutoSize = true
|
||||
};
|
||||
|
||||
_numLogRetention = new NumericUpDown
|
||||
{
|
||||
Left = 305, Top = 200, Width = 55, Minimum = 0, Maximum = 3650,
|
||||
Value = System.Math.Max(0, System.Math.Min(3650, _settings.LogRetentionDays))
|
||||
};
|
||||
|
||||
var lblShared = new Label
|
||||
{
|
||||
Text = "Gemeinsames Verzeichnis fuer Sync-Sperre (Mehrplatz, optional):",
|
||||
Left = 20, Top = 206, AutoSize = true
|
||||
Left = 20, Top = 240, AutoSize = true
|
||||
};
|
||||
|
||||
_txtSharedDir = new TextBox
|
||||
{
|
||||
Left = 20, Top = 228, Width = 250,
|
||||
Left = 20, Top = 262, Width = 250,
|
||||
Text = _settings.SharedDirectory
|
||||
};
|
||||
|
||||
_btnBrowseShared = new Button
|
||||
{
|
||||
Text = "...", Left = 274, Top = 227, Width = 36, Height = 24
|
||||
Text = "...", Left = 274, Top = 261, Width = 36, Height = 24
|
||||
};
|
||||
_btnBrowseShared.Click += (s, e) => BrowseSharedDir();
|
||||
|
||||
@@ -98,26 +112,26 @@ namespace StarfaceOutlookSync.UI
|
||||
{
|
||||
Text = "Netzlaufwerk/UNC, das alle Arbeitsplaetze erreichen. Leer = keine\n" +
|
||||
"clientuebergreifende Sperre (nur Schutz auf diesem PC).",
|
||||
Left = 20, Top = 254, Width = 330, Height = 32,
|
||||
Left = 20, Top = 288, Width = 330, Height = 32,
|
||||
ForeColor = Color.Gray, Font = new Font("Segoe UI", 8)
|
||||
};
|
||||
|
||||
_btnSave = new Button
|
||||
{
|
||||
Text = "Speichern", Left = 95, Top = 300, Width = 85, Height = 28,
|
||||
Text = "Speichern", Left = 95, Top = 334, Width = 85, Height = 28,
|
||||
DialogResult = DialogResult.None
|
||||
};
|
||||
_btnSave.Click += (s, e) => Save();
|
||||
|
||||
_btnCancel = new Button
|
||||
{
|
||||
Text = "Abbrechen", Left = 189, Top = 300, Width = 85, Height = 28,
|
||||
Text = "Abbrechen", Left = 189, Top = 334, Width = 85, Height = 28,
|
||||
DialogResult = DialogResult.Cancel
|
||||
};
|
||||
|
||||
Size = new Size(380, 390);
|
||||
Size = new Size(380, 424);
|
||||
Controls.AddRange(new Control[] { _chkStartMinimized, _chkSyncOnStart, _chkAutoAcceptOutlook, lblHint,
|
||||
_chkNotifGeneral, _chkNotifWarn,
|
||||
_chkNotifGeneral, _chkNotifWarn, lblLogRetention, _numLogRetention,
|
||||
lblShared, _txtSharedDir, _btnBrowseShared, lblSharedHint, _btnSave, _btnCancel });
|
||||
AcceptButton = _btnSave;
|
||||
CancelButton = _btnCancel;
|
||||
@@ -144,8 +158,13 @@ namespace StarfaceOutlookSync.UI
|
||||
_settings.AutoAcceptOutlookPrompt = _chkAutoAcceptOutlook.Checked;
|
||||
_settings.NotificationsEnabled = _chkNotifGeneral.Checked;
|
||||
_settings.NotifyWarningsErrors = _chkNotifWarn.Checked;
|
||||
_settings.LogRetentionDays = (int)_numLogRetention.Value;
|
||||
_settings.SharedDirectory = _txtSharedDir.Text.Trim();
|
||||
_settings.Save();
|
||||
|
||||
// Sofort anwenden, damit der Effekt direkt sichtbar ist.
|
||||
Logger.PruneOlderThan(_settings.LogRetentionDays);
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user