Skip to content

[Foundation] FT-6: Make logging thread-safe and per-run scoped (prereq for parallel execution) #311

Description

@ChrisonSimtian

Summary

Make logging thread-safe and per-run scoped, so concurrent target execution (FT-8) is safe. Prerequisite for parallelism.

Findings (file:line)

  • Logging.cs:214InMemorySink.Instance with an unlocked List<LogEvent> (_logEvents); concurrent emits race.
  • Logging.cs:239-243 — target-context enricher uses a static s_property (SetAndRestore), not safe under concurrent targets.
  • Logging.cs:20 — global LevelSwitch; per-run level should live on the context.

Scope

  • Lock or use a concurrent collection for InMemorySink.
  • Replace the enricher's static s_property with AsyncLocal so per-target context is correct under concurrency.
  • Per-run level switch held on BuildContext.Logging.

Acceptance criteria

  • Concurrent emits don't race (stress test).
  • Per-target log context is correct under parallel execution.

Notes

  • Non-breaking.
  • Depends on: FT-2. Prerequisite for: FT-8.
  • Size: M.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions