Skip to content

Commit f39b79c

Browse files
committed
feat(cleanup): automatische & periodische Log‑Aufräumfunktion, Einstellungen, Befehle & Tests ✨
- Neue Einstellungen: magentoLogViewer.enableAutoCleanup, autoCleanupMaxAge, enablePeriodicCleanup, periodicCleanupInterval - Befehle hinzugefügt/registriert: cleanupOldLogFiles, togglePeriodicCleanup (inkl. View/Menu‑Einträge) - Automatisches Cleanup beim Aktivieren; periodischer Scheduler mit Start/Stop und Re‑Start bei Config‑Änderungen - Cache‑Invalidierung & UI‑Refresh nach Aufräumvorgängen - Hilfsfunktionen: parseTimeDuration, isFileOlderThan, startPeriodicCleanup, stopPeriodicCleanup, parsePeriodicInterval - Tests: autoCleanup.test.ts für Dauer‑Parsing und Dateialter - README & CHANGELOG aktualisiert; package.json Version auf 1.18.0 erhöht
1 parent ff5f1c4 commit f39b79c

File tree

6 files changed

+467
-22
lines changed

6 files changed

+467
-22
lines changed

CHANGELOG.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ All notable changes to the "magento-log-viewer" extension will be documented in
55

66
## Next release
77

8-
- config: Default Magento root is now the workspace root if unset; paths are stored relative to workspace
9-
- ux: Added "Select Root Folder" command for easy Magento root configuration and automatic folder picker when path is missing or invalid
10-
- fix: Log and report files now load automatically without manual refresh; improved error handling with direct path selection
8+
- config: Default Magento root uses workspace root if unset; paths stored relative to workspace
9+
- ux: "Select Root Folder" command for easy Magento root setup; auto folder picker if path missing/invalid
10+
- fix: Log and report files auto-load; improved error handling with direct path selection
11+
- Files older than configured age are automatically deleted with proper cache invalidation
12+
- **NEW**: Added periodic cleanup functionality (cron-like scheduling)
13+
- New setting `magentoLogViewer.enablePeriodicCleanup` to enable periodic cleanup
14+
- New setting `magentoLogViewer.periodicCleanupInterval` with predefined intervals (5min-24h)
15+
- Toggle button (sync icon) for quick enable/disable of periodic cleanup
16+
- Automatic restart of periodic cleanup when configuration changes
17+
- Proper cleanup disposal on extension deactivation
1118

1219
---
1320

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ The Magento Log Viewer extension for Visual Studio Code provides a convenient wa
2525
- Individual report file deletion through context menu
2626
- Automatic update notifications for new extension versions
2727
- Line-by-line navigation within log files
28-
- Collapsible sections for identical report error titles
29-
- Project setting retention between workspace sessions
28+
- Collapsible sections for identical report error titles\n- Project setting retention between workspace sessions\n- **Automatic Log File Cleanup** - Configurable auto-deletion of old log files based on age (disabled by default)
29+
- **Periodic Cleanup (Cron-like)** - Run cleanup automatically at regular intervals (5min to 24h)
3030

3131
## Setup
3232

@@ -50,9 +50,7 @@ Note: Settings are workspace-specific, allowing different configurations for eac
5050
- **Refresh**: Click the refresh icon or wait for auto-update
5151
- **Navigate**: Click on log entries to jump to specific lines
5252
- **Filter**: Expand log files to see entries grouped by severity
53-
- **Group by Message**: Enable or disable grouping of log entries by message content in the settings. When enabled, the counter will display "grouped" (e.g., `INFO (128, grouped)`).
54-
- **Delete Reports**: Right-click on a report file entry and select "Delete Report File" from the context menu
55-
- **View Updates**: Review update notifications when the extension is updated with links to changelog and GitHub
53+
- **Group by Message**: Enable or disable grouping of log entries by message content in the settings. When enabled, the counter will display "grouped" (e.g., `INFO (128, grouped)`).\n- **Delete Reports**: Right-click on a report file entry and select "Delete Report File" from the context menu\n- **Auto Cleanup**: Automatically delete old log files based on configured age\n - **Enable/Disable**: Control automatic cleanup via `magentoLogViewer.enableAutoCleanup` setting (disabled by default)\n - **Configure Age**: Set maximum file age with `magentoLogViewer.autoCleanupMaxAge` (default: \"30d\")\n - **Supported Formats**: Use time formats like \"30min\" (30 minutes), \"2h\" (2 hours), \"7d\" (7 days), \"2w\" (2 weeks), \"3M\" (3 months)\n - **Manual Cleanup**: Click the clock icon in the log view header to run cleanup manually\n - **Automatic Run**: Cleanup runs silently on extension startup (if enabled)\n- **View Updates**: Review update notifications when the extension is updated with links to changelog and GitHub
5654

5755
## Requirements
5856

package.json

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magento-log-viewer",
33
"displayName": "Magento Log Viewer",
44
"description": "A Visual Studio Code extension to view and manage Magento log files.",
5-
"version": "1.17.1",
5+
"version": "1.18.0",
66
"publisher": "MathiasElle",
77
"icon": "resources/logo.png",
88
"repository": {
@@ -96,6 +96,16 @@
9696
"command": "magento-log-viewer.selectMagentoRootFromSettings",
9797
"title": "Magento Log Viewer: Select Root Folder",
9898
"category": "Magento Log Viewer"
99+
},
100+
{
101+
"command": "magento-log-viewer.cleanupOldLogFiles",
102+
"title": "Clean Up Old Log Files",
103+
"icon": "$(clock)"
104+
},
105+
{
106+
"command": "magento-log-viewer.togglePeriodicCleanup",
107+
"title": "Toggle Periodic Cleanup",
108+
"icon": "$(sync)"
99109
}
100110
],
101111
"configuration": {
@@ -158,6 +168,33 @@
158168
"default": false,
159169
"description": "Show cache statistics in developer console (useful for debugging performance)",
160170
"scope": "resource"
171+
},
172+
"magentoLogViewer.enableAutoCleanup": {
173+
"type": "boolean",
174+
"default": false,
175+
"description": "Automatically delete log files older than the specified time period",
176+
"scope": "resource"
177+
},
178+
"magentoLogViewer.autoCleanupMaxAge": {
179+
"type": "string",
180+
"default": "30d",
181+
"pattern": "^\\d+(min|[hdwM])$",
182+
"patternErrorMessage": "Format: Number followed by min (minutes), h (hours), d (days), w (weeks), or M (months). Example: 30min, 2h, 7d, 2w, 3M",
183+
"markdownDescription": "Maximum age of log files before automatic deletion. Format: Number + unit (min=minutes, h=hours, d=days, w=weeks, M=months). Examples: `30min`, `2h`, `7d`, `2w`, `3M`",
184+
"scope": "resource"
185+
},
186+
"magentoLogViewer.enablePeriodicCleanup": {
187+
"type": "boolean",
188+
"default": false,
189+
"description": "Enable periodic automatic cleanup that runs at regular intervals (like cron)",
190+
"scope": "resource"
191+
},
192+
"magentoLogViewer.periodicCleanupInterval": {
193+
"type": "string",
194+
"default": "1h",
195+
"enum": ["5min", "10min", "15min", "30min", "1h", "2h", "6h", "12h", "24h"],
196+
"markdownDescription": "How often to run the periodic cleanup. Examples: `5min`, `30min`, `1h`, `6h`, `24h`",
197+
"scope": "resource"
161198
}
162199
}
163200
},
@@ -265,6 +302,16 @@
265302
"when": "view == logFiles && magentoLogViewer.hasMagentoRoot",
266303
"group": "navigation@5"
267304
},
305+
{
306+
"command": "magento-log-viewer.cleanupOldLogFiles",
307+
"when": "view == logFiles && magentoLogViewer.hasMagentoRoot",
308+
"group": "navigation@6"
309+
},
310+
{
311+
"command": "magento-log-viewer.togglePeriodicCleanup",
312+
"when": "view == logFiles && magentoLogViewer.hasMagentoRoot",
313+
"group": "navigation@7"
314+
},
268315
{
269316
"command": "magento-log-viewer.refreshReportFiles",
270317
"when": "view == reportFiles && magentoLogViewer.hasMagentoRoot",

src/extension.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { promptMagentoProjectSelection, showErrorMessage, activateExtension, isValidPath, deleteReportFile, clearFileContentCache, selectMagentoRootFolder, selectMagentoRootFolderDirect, getEffectiveMagentoRoot, selectMagentoRootFromSettings } from './helpers';
2+
import { promptMagentoProjectSelection, showErrorMessage, activateExtension, isValidPath, deleteReportFile, clearFileContentCache, selectMagentoRootFolder, selectMagentoRootFolderDirect, getEffectiveMagentoRoot, selectMagentoRootFromSettings, autoCleanupOldLogFiles, stopPeriodicCleanup } from './helpers';
33
import { LogItem, ReportViewerProvider } from './logViewer';
44
import { showUpdateNotification } from './updateNotifier';
55

@@ -78,6 +78,9 @@ export function activate(context: vscode.ExtensionContext): void {
7878
}
7979

8080
export function deactivate(): void {
81+
// Stop periodic cleanup
82+
stopPeriodicCleanup();
83+
8184
// Clear any context values we set
8285
vscode.commands.executeCommand('setContext', 'magentoLogViewer.hasMagentoRoot', undefined);
8386

0 commit comments

Comments
 (0)