Define cached threshold behavior for isEnabled
Document and test explicit refresh boundaries for isEnabled guards, and only read the shared root threshold when no namespace threshold applies. Include the portable Nimble configuration loader.
This commit is contained in:
1 parent
14e71c72ca
commit
011780e6ab
5 files changed
+88
-10
No files matched your search
+7
-3
@@ -84,7 +84,11 @@ the unsafe forms are tested as compilation failures.
|
||||
|
||||
The in-process regression tests are deterministic. The lifetime suite checks
|
||||
copying, self-assignment, replacement, moving, container copies, and exporting a
|
||||
handle from a local service. Refresh tests verify that repeated clone failures
|
||||
handle from a local service. `isEnabled` tests verify that namespace thresholds
|
||||
remain cached until an explicit refresh, a logging call, or `getLogger`, while
|
||||
the root fallback is read from shared state. This behavior is intentional so
|
||||
guards can avoid configuration refresh work.
|
||||
Refresh tests verify that repeated clone failures
|
||||
preserve the old appenders and thresholds, release partial replacements, and
|
||||
allow a later retry without another configuration change. A successful refresh
|
||||
releases the replaced cache and installs both appenders and thresholds.
|
||||
@@ -113,8 +117,8 @@ The suite provides targeted regressions; it does not exhaust thread scheduling
|
||||
or ORC cycle-collector interleavings.
|
||||
|
||||
The ownership scenarios, lifetime suite, and appender-state cleanup regression
|
||||
exercise the new ownership contracts. `isEnabled` freshness,
|
||||
local-time timestamp construction, and allocator reports remain for
|
||||
exercise the new ownership contracts. Local-time timestamp construction and
|
||||
allocator reports remain for
|
||||
subsequent work.
|
||||
|
||||
The standalone `ownership.nim` regression suite passed AddressSanitizer and
|
||||
|
||||
+28
-1
@@ -112,7 +112,7 @@ suite "ORC service handle lifetime":
|
||||
check destroyed == 1
|
||||
|
||||
suite "ORC ownership and configuration regressions":
|
||||
test "isEnabled observes a namespace change before any log call":
|
||||
test "isEnabled uses cached namespace thresholds until a refresh":
|
||||
var service = initLogService()
|
||||
service.setThreshold("worker", lvlError)
|
||||
let local = service.threadLocalRef()
|
||||
@@ -122,8 +122,35 @@ suite "ORC ownership and configuration regressions":
|
||||
# Simulate a change from another service handle without introducing a
|
||||
# reference-count race into this deterministic configuration test.
|
||||
service.setThreshold("worker", lvlInfo)
|
||||
check not logger.isEnabled(lvlInfo)
|
||||
|
||||
local.ensureFreshness()
|
||||
check logger.isEnabled(lvlInfo)
|
||||
|
||||
# A stale true result can become false when the logging call refreshes.
|
||||
service.setThreshold("worker", lvlError)
|
||||
check logger.isEnabled(lvlInfo)
|
||||
logger.info("filtered after refreshing configuration")
|
||||
check not logger.isEnabled(lvlInfo)
|
||||
|
||||
# Creating another logger also refreshes their shared local service.
|
||||
service.setThreshold("worker", lvlInfo)
|
||||
check not logger.isEnabled(lvlInfo)
|
||||
discard local.getLogger("another")
|
||||
check logger.isEnabled(lvlInfo)
|
||||
|
||||
test "isEnabled reads the shared root fallback without refreshing namespaces":
|
||||
var service = initLogService(rootLevel = lvlError)
|
||||
let local = service.threadLocalRef()
|
||||
let logger = local.getLogger("worker")
|
||||
check not logger.isEnabled(lvlInfo)
|
||||
|
||||
service.setRootThreshold(lvlInfo)
|
||||
service.setThreshold("worker", lvlError)
|
||||
check logger.isEnabled(lvlInfo)
|
||||
local.ensureFreshness()
|
||||
check not logger.isEnabled(lvlInfo)
|
||||
|
||||
test "a failed refresh is retried without another configuration change":
|
||||
var control: CloneControl
|
||||
var service = initLogService()
|
||||
|
||||
Reference in new issue
Block a user