logging: address review of the breadcrumbs

Drop the non-distinct song comparison (sum of album song counts double-counts compilations), skip redaction for dropped lines via a level check, defer the startup prune off the main thread and cap the writer queue, and only warn about a stall against the still-current player. Reward the scrobble info line and cover the new preferences/level toggles with tests.
This commit is contained in:
austinried
2026-10-09 07:58:55 +00:00
parent 9695d83b1a
commit 779131c766
8 changed files with 54 additions and 13 deletions
@@ -173,6 +173,21 @@ class UserPreferencesTest {
prefs.setLastSeed(ArtworkSeedValue("art:2", 0xFF778899.toInt(), null))
assertEquals(ArtworkSeedValue("art:2", 0xFF778899.toInt(), null), prefs.lastSeed())
file.delete()
}
@Test
fun verboseLoggingDefaultsOffAndRoundTrips() =
runTest {
val file = File.createTempFile("user-prefs", ".preferences_pb").apply { delete() }
val store = PreferenceDataStoreFactory.create(scope = backgroundScope) { file }
val prefs = UserPreferences(store)
assertEquals(false, prefs.verboseLogging().first())
prefs.setVerboseLogging(true)
assertEquals(true, prefs.verboseLogging().first())
file.delete()
}
}
@@ -86,6 +86,19 @@ class LogFileStoreTest {
assertTrue(text, text.contains("loud"))
}
@Test
fun setMinLevelChangesWhatIsWritten() {
val store = LogFileStore(root, LogLevel.WARN)
store.setMinLevel(LogLevel.VERBOSE)
store.write(LogLevel.VERBOSE, "x", "verbose-line", null)
store.setMinLevel(LogLevel.ERROR)
store.write(LogLevel.INFO, "x", "info-line", null)
store.flush()
val text = store.files().single().readText()
assertTrue(text, text.contains("verbose-line"))
assertFalse(text, text.contains("info-line"))
}
@Test
fun rotatesWhenFileExceedsCap() {
val store = LogFileStore(root, LogLevel.VERBOSE, maxFileBytes = 1)