Create log timestamps in UTC to avoid local-time races
Use getTime().utc in both message constructors, document the timezone change, and cover concurrent construction and structured formatting. Restore ordinary logging calls in the parallel writer fixture. Validation: 32 unit tests and 29 regression tests pass. Timestamp sanitizer checks pass under UTC and non-UTC timezones. The full suite retains the known allocator reports in factory-state and allocator.
This commit is contained in:
1 parent
011780e6ab
commit
46245b3f1e
6 files changed
+48
-17
No files matched your search
@@ -158,8 +158,13 @@ proc factoryWorker(source: ptr LogService) {.thread.} =
|
||||
proc timestampWorker() {.thread.} =
|
||||
awaitStart()
|
||||
for i in 0 ..< iterations:
|
||||
let msg = initLogMessage("worker", lvlInfo, "message")
|
||||
doAssert msg.msg == "message"
|
||||
for msg in [initLogMessage("worker", lvlInfo, "message"),
|
||||
initLogMessage("worker", lvlInfo, %*{"msg": "message"})]:
|
||||
doAssert msg.msg == "message"
|
||||
doAssert msg.ts.timezone.name == "Etc/UTC"
|
||||
doAssert msg.ts.utcOffset == 0
|
||||
doAssert not msg.ts.isDst
|
||||
doAssert parseJson(formatJsonStructuredLog(msg))["ts"].getStr.len > 0
|
||||
|
||||
proc collectorWorker(collector: LoggedMessages) {.thread.} =
|
||||
# Construct every managed field in this worker, including the timezone.
|
||||
|
||||
Reference in new issue
Block a user