Add debug object trace writer#3677
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 098f06ee13
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /// The object field value must implement `Debug`. In release builds this | ||
| /// value is `None`, so `<?` skips the template and does not evaluate | ||
| /// field values. | ||
| pub let debug_object : DebugObject? = Some({ |
There was a problem hiding this comment.
Avoid reusing one mutable debug writer
In debug builds this exposes a single package-level DebugObject with a mutable buffer, so any field expression that also logs via debug_object <? ... re-enters the same writer: the inner write_object_begin resets the outer buffer and the inner write_object_end resets first, causing the outer trace to lose or split fields. This affects nested helper calls that use the prelude-exported debug_object; the writer needs per-invocation state (or a stack) rather than a shared singleton.
Useful? React with 👍 / 👎.
Coverage Report for CI Build 4652Coverage decreased (-0.003%) to 94.244%Details
Uncovered Changes
Coverage Regressions1 previously-covered line in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
Summary
@debug.debug_objectas a debug-only optional object-template writerNonein release mode so<?skips evaluating debug fieldsdebug_objectfrompreludeExample:
Known issues / follow-ups
debug_objectis a package-level optional writer, so nested use can reuse the same buffer. A nesteddebug_object <? ...inside a field expression can interfere with the outer trace.moonbitlang/coreartifacts from both release mode and debug mode can be used.Tests
moon fmtmoon check debugmoon check --release debugmoon test debugmoon test --release debugmoon check preludemoon test preludemoon infomoon check