Removes the chitter-chatter of folder state changes from the info level, while adding the error state at warning level and a corresponding clearing of the error state at info level. Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/syncthing/syncthing/internal/slogutil"
|
||||||
"github.com/syncthing/syncthing/lib/events"
|
"github.com/syncthing/syncthing/lib/events"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -125,11 +126,12 @@ func (s *stateTracker) setState(newState folderState) {
|
|||||||
eventData["duration"] = time.Since(s.changed).Seconds()
|
eventData["duration"] = time.Since(s.changed).Seconds()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slog.Debug("Folder changed state", "folder", s.folderID, "state", newState, "from", s.current)
|
||||||
|
|
||||||
s.current = newState
|
s.current = newState
|
||||||
s.changed = time.Now().Truncate(time.Second)
|
s.changed = time.Now().Truncate(time.Second)
|
||||||
|
|
||||||
s.evLogger.Log(events.StateChanged, eventData)
|
s.evLogger.Log(events.StateChanged, eventData)
|
||||||
slog.Info("Folder changed state", "folder", s.folderID, "state", newState)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// getState returns the current state, the time when it last changed, and the
|
// getState returns the current state, the time when it last changed, and the
|
||||||
@@ -156,6 +158,12 @@ func (s *stateTracker) setError(err error) {
|
|||||||
"from": s.current.String(),
|
"from": s.current.String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err != nil && s.current != FolderError {
|
||||||
|
slog.Warn("Folder is in error state", slog.String("folder", s.folderID), slogutil.Error(err))
|
||||||
|
} else if err == nil && s.current == FolderError {
|
||||||
|
slog.Info("Folder error state was cleared", slog.String("folder", s.folderID))
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
eventData["error"] = err.Error()
|
eventData["error"] = err.Error()
|
||||||
s.current = FolderError
|
s.current = FolderError
|
||||||
|
|||||||
Reference in New Issue
Block a user