Skip to content

Test logging refactoring#1638

Merged
sipsorcery merged 1 commit into
sipsorcery-org:masterfrom
paulomorgado:test-logging
May 26, 2026
Merged

Test logging refactoring#1638
sipsorcery merged 1 commit into
sipsorcery-org:masterfrom
paulomorgado:test-logging

Conversation

@paulomorgado
Copy link
Copy Markdown
Contributor

Summary

This updates test logging to remove reflection-based method name lookup and replaces the Serilog-based xUnit logging setup with MartinCostello.Logging.XUnit.

Part of #1434

Why

Using [CallerMemberName] is a better fit for test log messages and scopes than System.Reflection.MethodBase.GetCurrentMethod() because the compiler supplies the caller name directly. That avoids reflection overhead, removes nullable/reflection-specific handling, and keeps the code simpler while still producing the same method names in test output.

MartinCostello.Logging.XUnit is also a lighter-weight option for test logging. It plugs directly into Microsoft.Extensions.Logging and ITestOutputHelper, so the tests no longer need a full Serilog logger configuration plus xUnit and console sinks just to write test output. This reduces test-only dependencies and keeps logging setup focused on the xUnit test scenario.

Changes

  • Added caller-member-name helpers for test method logging.
  • Replaced reflection calls in test log messages and scopes.
  • Switched affected test logger factories from Serilog to MartinCostello.Logging.XUnit.
  • Updated test project package references to remove Serilog test logging packages.

Remove reflection-based method name lookup from test log messages and scopes by using caller member name helpers. Switch test logger factories from Serilog sinks to MartinCostello.Logging.XUnit and update test package references accordingly.

Replace Serilog test logging with MartinCostello logger.
@sipsorcery sipsorcery merged commit 74a84f5 into sipsorcery-org:master May 26, 2026
6 checks passed
@paulomorgado paulomorgado deleted the test-logging branch May 26, 2026 07:24
@paulomorgado paulomorgado mentioned this pull request Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants