fix(site-runtime): TraceCapturingLogger rejects double-wrapping; ScriptLogger clip keeps surrogate pairs (Task 4 review)

This commit is contained in:
Joseph Doherty
2026-09-09 11:42:40 -04:00
parent 14fb8c889b
commit aaec993b84
4 changed files with 125 additions and 11 deletions
@@ -135,6 +135,27 @@ public class TraceCapturingLoggerTests
Assert.Equal(stepId, Assert.Single(rows).StepEventId);
}
[Fact]
public void Ctor_RejectsAnAlreadyDecoratedLogger()
{
// Wrapping twice would forward each script line through two capture stages and emit two
// runtime rows per line — and would burn the run's line cap at double rate.
var (already, _, _) = Make();
var sink = new ScriptLogger(new RecordingLogger(), emit: null, maxLines: 200, "i", "s", null);
var ex = Assert.Throws<ArgumentException>(() => new TraceCapturingLogger(already, sink));
Assert.Equal("inner", ex.ParamName);
}
[Fact]
public void Ctor_RequiresBothCollaborators()
{
var sink = new ScriptLogger(new RecordingLogger(), emit: null, maxLines: 200, "i", "s", null);
Assert.Throws<ArgumentNullException>(() => new TraceCapturingLogger(null!, sink));
Assert.Throws<ArgumentNullException>(() => new TraceCapturingLogger(new RecordingLogger(), null!));
}
[Fact]
public void BeginScope_DelegatesToTheInnerLogger()
{