Skip to content

Log every use case and unexpected tool errors - #37

Merged
stphnwlsh merged 2 commits into
mainfrom
feature/logging
Nov 3, 2026
Merged

stphnwlsh merged 2 commits into
mainfrom
feature/logging

Conversation

@stphnwlsh

@stphnwlsh stphnwlsh commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Until now nothing we wrote logged anything. This gives each request a clear trail, the same as CleanMinimalApi #66.

  • LoggingBehaviour wraps every use case and logs how it ended, at Information, with the request name and its time in milliseconds: handled, failed validation (with the property names, never the values) or found nothing. It's registered before ValidationBehaviour, so it sees validation failures too. The messages are [LoggerMessage] source-generated, and the time comes from TimeProvider.
  • Unexpected tool errors are logged. ToolErrorFilter turns them into a tool error for the model, so nothing else ever saw them. It now logs them as Error, with the exception and the tool's name. Resources and prompts already get logged by the MCP SDK when ProtocolErrorFilter lets an exception through.
  • Information is the default level, and appsettings.local.json lowers it to Debug.
  • TimeProvider.System is registered with TryAddSingleton in both AddApplication and AddInfrastructure, so each layer works on its own without registering the clock twice.
  • FakeLogger (Microsoft.Extensions.Diagnostics.Testing, MIT) checks the messages in the behaviour and filter tests.
  • The serilog, mediator, time-provider, errors-and-exceptions, unit-tests and api-conventions skills describe all of this.

@github-actions github-actions Bot added the enhancement New feature or request label Nov 3, 2026
@stphnwlsh stphnwlsh self-assigned this Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Build Pipeline

✅ Ready to merge. Every stage passed.

Stage Result Details
Build 🟢 Passed Version 2026.11.03.145-pr-37 · Template package 204 KB
Test 🟢 Passed 232 passed · 0 failed · 0 skipped · Template installs, builds and passes its tests
Coverage 🟢 Passed 100% (771 of 771 lines) · Needs 95%
Static Analysis 🟢 Passed No open CodeQL alerts
Dependency Review 🟢 Passed 0 vulnerable packages · 0 licence problems
Container Scan 🟢 Passed Image starts and answers · No open Trivy alerts

Commit 73cd8be · Full run

@stphnwlsh
stphnwlsh merged commit be0af9d into main Nov 3, 2026
13 checks passed
@stphnwlsh
stphnwlsh deleted the feature/logging branch November 3, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

2 participants