Skip to content

Consolidate duplicate test logger implementations in logging specs #723

@Aaronontheweb

Description

@Aaronontheweb

Summary

There are three separate test logger implementations in src/Akka.Hosting.Tests/Logging/ that share significant overlap:

  1. TestLogger (TestLogger.cs) — captures messages by log level
  2. SemanticTestLogger (SemanticLoggingSpecs.cs) — captures message + structured state dictionary
  3. BugReproTestSink (Issue701SemanticLoggingRegressionSpecs.cs) — captures message + structured state dictionary

Implementations 2 and 3 are ~95% identical:

  • Both implement ILogger
  • Both capture the formatted message and enumerate IEnumerable<KeyValuePair<string, object>> state into a dictionary
  • Both write to ITestOutputHelper
  • Only minor naming differences (Entries vs LogEntries, BugReproLogEntry vs LogEntry)

Proposed Change

Extract a shared StructuredTestLogger and CapturedLogEntry into a common file (e.g., SharedLoggingTestUtilities.cs) and have both test classes use it. This reduces maintenance burden when the logging infrastructure changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions