-
Type: Task
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
8
Currently, adding assert.eq("APPLE", "BANANA", "test assertion message") to test_assert.js will produce the following log output:
[js_test:test_assert] 2024-11-08T22:14:36.340Z assert: ["APPLE"] != ["BANANA"] are not equal : test assertion message [js_test:test_assert] doassert@src/mongo/shell/assert.js:20:14 [js_test:test_assert] assert.eq@src/mongo/shell/assert.js:176:17 [js_test:test_assert] @test_assert.js:1:8 [js_test:test_assert] uncaught exception: Error: ["APPLE"] != ["BANANA"] are not equal : MESSAGE : test assertion message [js_test:test_assert] doassert@src/mongo/shell/assert.js:20:14 [js_test:test_assert] assert.eq@src/mongo/shell/assert.js:176:17 [js_test:test_assert] @test_assert.js:1:8 [js_test:test_assert] failed to load: test_assert.js [js_test:test_assert] exiting with code -3
At least for the assertion message, the desired structured message format would be something like structured log format where arg1 and arg2 may be something else than strings:
{ "t": {"$date": "2024-11-08T22:14:36.340+00:00"}, "s": "E", "msg": "assert.eq() failed : test assertion message", "attr": { "arg1": "APPLE", "arg2": "BANANA" } }
The original log is somewhat redundant, because assert.eq() traces its arguments, packs everything into an exception and throws it. We should check whether throwing is necessary and whether we could print uncaught exceptions in JSON format as well.