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
+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