mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-14 18:26:11 -04:00
feat(debug): Flip the debug flag when the recorder starts writing
The flag was only written from committed recorder module state, which publishes after the recording header has been read. That read is bounded at 5s, so for up to five seconds the file logger is live while the flag still says false, and diagnostics keyed off it are missing from exactly the window a reporter uses to reproduce a screen-off issue. The module-state writer stays: it covers a resumed session and any path that reaches isRecording=false without going through Recorder.stop(). A rolled-back start self-corrects, because the rollback stops the recorder before publishing the failure. BaseTest resets the flag per test instance because it is JVM-global. It goes into init rather than the companion teardown, which uses JUnit 5's @AfterAll and never fires under the JUnit 4 Robolectric runner.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package eu.darken.capod.common.debug.recording.core
|
||||
|
||||
import eu.darken.capod.common.TimeSource
|
||||
import eu.darken.capod.common.debug.Bugs
|
||||
import eu.darken.capod.common.debug.logging.FileLogger
|
||||
import eu.darken.capod.common.debug.logging.Logging
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.INFO
|
||||
@@ -33,6 +34,10 @@ class Recorder @Inject constructor(
|
||||
it.start()
|
||||
Logging.install(it)
|
||||
log(TAG, INFO) { "Now logging to file!" }
|
||||
// Flipped here rather than only from the committed module state: that publishes after
|
||||
// the recording header has been read, and everything written in that window would miss
|
||||
// the debug-only diagnostics that key off this flag.
|
||||
Bugs.isDebug.value = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +57,7 @@ class Recorder @Inject constructor(
|
||||
} finally {
|
||||
fileLogger = null
|
||||
this@Recorder.path = null
|
||||
Bugs.isDebug.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package testhelpers
|
||||
|
||||
import eu.darken.capod.common.debug.Bugs
|
||||
import eu.darken.capod.common.debug.logging.Logging
|
||||
import eu.darken.capod.common.debug.logging.Logging.Priority.VERBOSE
|
||||
import eu.darken.capod.common.debug.logging.log
|
||||
@@ -12,6 +13,10 @@ open class BaseTest {
|
||||
init {
|
||||
Logging.clearAll()
|
||||
Logging.install(JUnitLogger())
|
||||
// JVM-global and written by anything that starts a debug recording. Reset per test instance
|
||||
// and not in a companion teardown: the JUnit 5 @AfterAll below never fires under the JUnit 4
|
||||
// Robolectric runner that the recorder tests use.
|
||||
Bugs.isDebug.value = false
|
||||
testClassName = this.javaClass.simpleName
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user