Skip to content

Add an example for logging format arguments with an exception - #101

Merged
michaelJustin merged 2 commits into
masterfrom
example-format-args-with-exception
Oct 14, 2026
Merged

michaelJustin merged 2 commits into
masterfrom
example-format-args-with-exception

Conversation

@michaelJustin

@michaelJustin michaelJustin commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • New examples/exception/LogException.dpr (+ .dproj): catches an exception and logs it with the (AFormat, AArgs, AException) overload from Add format-args-plus-exception overloads to ILogger #97. It uses the call daraja-framework now makes (Use slf4p's format-args-plus-exception overloads daraja-framework#570):
    Log.Warn('TdjWebFilterHolder.Stop: %s', [E.Message], E);
  • examples/README.md: a table row and a section with the output:
    [20:44:46.069] WARN TdjWebFilterHolder TdjWebFilterHolder.Stop: error in destroy
      EDestroyFailed
      error in destroy
    [20:44:46.069] WARN TdjWebFilterHolder TdjWebFilterHolder.Stop:
      EDestroyFailed
      error in destroy
    
  • For comparison, it also logs the same exception with a plain message, Log.Warn('TdjWebFilterHolder.Stop:', E). The README shows both outputs and notes that putting E.Message into the message as well shows it twice.
  • CHANGELOG: an entry under Internal / toolchain.

Test plan

  • Delphi 2009 (dcc32) builds and runs it, with the output shown above.
  • FPC 3.2.2 (fpc -Mdelphi -Fu../../src/main LogException.dpr) builds and runs it, with the same output.

🤖 Generated with Claude Code

examples/exception/LogException.dpr catches an exception and logs it
with the (AFormat, AArgs, AException) overload added in #97, using the
call Daraja makes when a Web Filter fails to stop. The examples README
shows the resulting SimpleLogger output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@michaelJustin michaelJustin added this to the 1.2.0 milestone Oct 14, 2026
Shows Log.Warn('TdjWebFilterHolder.Stop:', E) next to the format-args
call, so the README can compare the two outputs: the exception's class
and message appear in both, so E.Message in the message repeats it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@michaelJustin
michaelJustin merged commit cd9b4fe into master Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant