Reduce API log noise

This commit is contained in:
Mikei386
2026-07-10 13:09:56 +02:00
parent 3f1b7cd781
commit 091c5ff175
8 changed files with 46 additions and 11 deletions
-1
View File
@@ -1 +0,0 @@
9c7e39a06a10ae9557796457e9ed754e9e0dcf65f12be39561276d9fce6cbc0b urbm-2026.07.10.r005-x86_64-1.txz
+1
View File
@@ -0,0 +1 @@
24660d70ea52abe59214ad8a56f31023cef090cb2fafeb557690870ed5790aa9 urbm-2026.07.10.r006-x86_64-1.txz
+6 -2
View File
@@ -2,13 +2,17 @@
<!DOCTYPE PLUGIN [
<!ENTITY name "urbm">
<!ENTITY author "Michael Roll">
<!ENTITY version "2026.07.10.r005">
<!ENTITY version "2026.07.10.r006">
<!ENTITY pluginURL "https://git.casaderoll.de/michael/URBM/raw/branch/main/dist/urbm.plg">
<!ENTITY packageURL "https://git.casaderoll.de/michael/URBM/raw/branch/main/dist/urbm-&version;-x86_64-1.txz">
<!ENTITY packageSHA256 "9c7e39a06a10ae9557796457e9ed754e9e0dcf65f12be39561276d9fce6cbc0b">
<!ENTITY packageSHA256 "24660d70ea52abe59214ad8a56f31023cef090cb2fafeb557690870ed5790aa9">
]>
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="&pluginURL;" min="7.0.0" support="https://git.casaderoll.de/michael/URBM/issues" icon="urbm.png">
<CHANGES>
### 2026.07.10.r006
- Stop logging high-frequency health, log, and activity polling requests unless they are slow or fail.
- Log snapshot file-listing requests immediately when they start and show a larger daemon log tail in the Protokolle tab.
### 2026.07.10.r005
- Log snapshot file-listing failures from the daemon and PHP bridge to `/var/log/urbm.log` so they appear in the Protokolle tab.
- Increase the daemon HTTP write timeout for large snapshot trees and return concrete backend errors instead of generic 500 responses where possible.
+28 -2
View File
@@ -332,7 +332,33 @@ func writeError(w http.ResponseWriter, err error) {
func requestLog(log *slog.Logger, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
started := time.Now()
next.ServeHTTP(w, r)
log.Info("api request", "method", r.Method, "path", r.URL.Path, "durationMs", time.Since(started).Milliseconds())
recorder := &statusRecorder{ResponseWriter: w, status: http.StatusOK}
next.ServeHTTP(recorder, r)
duration := time.Since(started)
if shouldLogRequest(r, recorder.status, duration) {
log.Info("api request", "method", r.Method, "path", r.URL.Path, "status", recorder.status, "durationMs", duration.Milliseconds())
}
})
}
type statusRecorder struct {
http.ResponseWriter
status int
}
func (r *statusRecorder) WriteHeader(status int) {
r.status = status
r.ResponseWriter.WriteHeader(status)
}
func shouldLogRequest(r *http.Request, status int, duration time.Duration) bool {
if status >= 400 || duration >= time.Second {
return true
}
switch r.URL.Path {
case "/v1/runs", "/v1/health", "/v1/logs":
return false
default:
return true
}
}
+2 -1
View File
@@ -68,7 +68,7 @@ func (s *Service) Config() model.Config { s.mu.RLock(); defer s.mu.RUnlo
func (s *Service) Runs() []model.Run { return s.queue.Snapshot() }
func (s *Service) Logs() map[string]any {
return map[string]any{
"daemon": tailFile("/var/log/urbm.log", 512*1024, 300),
"daemon": tailFile("/var/log/urbm.log", 1024*1024, 1000),
"runs": runsWithLogs(s.queue.Snapshot(), 25),
}
}
@@ -386,6 +386,7 @@ func (s *Service) RepositoryStats(ctx context.Context) []model.RepositoryStats {
func (s *Service) SnapshotFiles(ctx context.Context, repoID, snapshot, path string) ([]map[string]any, error) {
started := time.Now()
s.log.Info("snapshot file listing started", "repoID", repoID, "snapshot", snapshot, "path", path)
repo, ok := s.repository(repoID)
if !ok {
return nil, errors.New("validation: unknown repository")
+5 -1
View File
@@ -2,13 +2,17 @@
<!DOCTYPE PLUGIN [
<!ENTITY name "urbm">
<!ENTITY author "Michael Roll">
<!ENTITY version "2026.07.10.r005">
<!ENTITY version "2026.07.10.r006">
<!ENTITY pluginURL "https://git.casaderoll.de/michael/URBM/raw/branch/main/dist/urbm.plg">
<!ENTITY packageURL "https://git.casaderoll.de/michael/URBM/raw/branch/main/dist/urbm-&version;-x86_64-1.txz">
<!ENTITY packageSHA256 "REPLACE_DURING_RELEASE">
]>
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="&pluginURL;" min="7.0.0" support="https://git.casaderoll.de/michael/URBM/issues" icon="urbm.png">
<CHANGES>
### 2026.07.10.r006
- Stop logging high-frequency health, log, and activity polling requests unless they are slow or fail.
- Log snapshot file-listing requests immediately when they start and show a larger daemon log tail in the Protokolle tab.
### 2026.07.10.r005
- Log snapshot file-listing failures from the daemon and PHP bridge to `/var/log/urbm.log` so they appear in the Protokolle tab.
- Increase the daemon HTTP write timeout for large snapshot trees and return concrete backend errors instead of generic 500 responses where possible.
+4 -4
View File
@@ -9,12 +9,12 @@ Tag="URBM Unraid Restic Backup Manager backup snapshots restore"
<?php
$pluginRoot = '/plugins/urbm';
?>
<link rel="stylesheet" href="<?= $pluginRoot ?>/assets/urbm.css?v=20260710r004">
<link rel="stylesheet" href="<?= $pluginRoot ?>/assets/urbm.css?v=20260710r006">
<div id="urbm-app" data-api="<?= $pluginRoot ?>/api.php">
<header class="bu-header">
<div class="bu-brand">
<img class="bu-logo" src="<?= $pluginRoot ?>/images/urbm.png?v=20260710r004" alt="URBM-Logo">
<div><h1>URBM <span class="bu-version">2026.07.10.r005</span></h1><p>Restic Backup Manager für Unraid</p></div>
<img class="bu-logo" src="<?= $pluginRoot ?>/images/urbm.png?v=20260710r006" alt="URBM-Logo">
<div><h1>URBM <span class="bu-version">2026.07.10.r006</span></h1><p>Restic Backup Manager für Unraid</p></div>
</div>
<div id="bu-health" class="bu-health" tabindex="0" data-tooltip="Zeigt, ob die URBM-Hintergrundkomponente erreichbar ist. Beispiel: 'Daemon online' bedeutet, dass Jobs gestartet werden können.">Verbindung wird hergestellt...</div>
</header>
@@ -33,4 +33,4 @@ $pluginRoot = '/plugins/urbm';
<div id="bu-tooltip" role="tooltip" aria-hidden="true"></div>
</div>
<script>window.URBM_CSRF = <?= json_encode($var['csrf_token'] ?? '') ?>;</script>
<script src="<?= $pluginRoot ?>/assets/urbm-2026.07.10.r005.js"></script>
<script src="<?= $pluginRoot ?>/assets/urbm-2026.07.10.r006.js"></script>