Accept a non-default IFormatProvider and use it for message rendering#228
Conversation
nblumhardt
left a comment
There was a problem hiding this comment.
Since this is a binary breaking change, we'll need to rev the major version of the sink.
Seeing more use of JsonValueFormatter.WriteQuotedJsonString suggests it'll be worth switching to use Utf8JsonWriter now - perhaps by first adding support upstream in Serilog's JsonValueFormatter - I'll dig in when I have a chance :)
IFormatProvider and use it for message rendering
|
Unfortunately, this won't have the desired effect server-side for tokens that don't carry format specifiers. E.g. A similar issue prevents us from using this trick to pre-render messages containing dotted property names (datalust/seq-tickets#2240). I think until we have a complete end-to-end solution, we should roll back message formatting, but keep format provider support for tokens with explicit format strings. The observable result will be the same, with today's Seq, and although some formatting won't be culture-specific, there won't be a confusing mismatch between what's displayed and what's searchable. Will send a PR :) |
Updated [Serilog](https://github.com/serilog/serilog) from 4.3.0 to 4.3.1. <details> <summary>Release notes</summary> _Sourced from [Serilog's releases](https://github.com/serilog/serilog/releases)._ ## 4.3.1 ## What's Changed * Remove SourceLink by @SimonCropp in serilog/serilog#2183 * Handle Exception.ToString failures in text formatter by @krisbiradar in serilog/serilog#2197 * Remove char[] allocation by @karpinsn in serilog/serilog#2198 * Remove backpressure from XMLDoc by @timothycoleman in serilog/serilog#2203 * Don't enable XDOC for tests by @nblumhardt in serilog/serilog#2205 * Target and test on net10 by @SimonCropp in serilog/serilog#2206 * Fix trimming error when Serilog is a transitive dependency by @Numpsy in serilog/serilog#2214 * Inline TraceId and SpanId JSON string formatting by @SimonCropp in serilog/serilog#2215 ## New Contributors * @krisbiradar made their first contribution in serilog/serilog#2197 * @karpinsn made their first contribution in serilog/serilog#2198 * @timothycoleman made their first contribution in serilog/serilog#2203 * @Numpsy made their first contribution in serilog/serilog#2214 **Full Changelog**: serilog/serilog@v4.3.0...v4.3.1 Commits viewable in [compare view](serilog/serilog@v4.3.0...v4.3.1). </details> Updated [Serilog.Sinks.Console](https://github.com/serilog/serilog-sinks-console) from 6.0.0 to 6.1.1. <details> <summary>Release notes</summary> _Sourced from [Serilog.Sinks.Console's releases](https://github.com/serilog/serilog-sinks-console/releases)._ ## 6.1.1 ## What's Changed * Report the number of escape characters formatted into themed sequence rendering by @nblumhardt in serilog/serilog-sinks-console#136 **Full Changelog**: serilog/serilog-sinks-console@v6.1.0...v6.1.1 ## 6.1.0 * #165 - support for `{UtcTimestamp}` in output templates (@ManuelRin) * #172, #173 - switch build to Serilog org standard (@nblumhardt) Commits viewable in [compare view](serilog/serilog-sinks-console@v6.0.0...v6.1.1). </details> Updated [Serilog.Sinks.File](https://github.com/serilog/serilog-sinks-file) from 6.0.0 to 7.0.0. <details> <summary>Release notes</summary> _Sourced from [Serilog.Sinks.File's releases](https://github.com/serilog/serilog-sinks-file/releases)._ ## 7.0.0 ## What's Changed * Fix issue with force-reopen after 30 minutes by @Falco20019 in serilog/serilog-sinks-file#337 * Support `ILoggingFailureListener` by @nblumhardt in serilog/serilog-sinks-file#342 ## New Contributors * @Falco20019 made their first contribution in serilog/serilog-sinks-file#337 **Full Changelog**: serilog/serilog-sinks-file@v4.1.0...v7.0.0 Commits viewable in [compare view](serilog/serilog-sinks-file@v6.0.0...v7.0.0). </details> Updated [Serilog.Sinks.Seq](https://github.com/datalust/serilog-sinks-seq) from 8.0.0 to 9.1.0. <details> <summary>Release notes</summary> _Sourced from [Serilog.Sinks.Seq's releases](https://github.com/datalust/serilog-sinks-seq/releases)._ ## 9.1.0 ## What's Changed * Upgrade .NET and dependencies by @liammclennan in datalust/serilog-sinks-seq#244 **Full Changelog**: datalust/serilog-sinks-seq@v9.0.0...v9.1.0 ## 9.0.0 ## What's Changed * Accept a non-default `IFormatProvider` and use it for message rendering by @liammclennan in datalust/serilog-sinks-seq#228, datalust/serilog-sinks-seq#229 * Don't write a spurious `SelfLog` event when disposing an unused sink in durable mode by @nblumhardt in datalust/serilog-sinks-seq#231 * Default to nesting (un-flattening) dotted property names by @nblumhardt in datalust/serilog-sinks-seq#232 * Use Actions build, .NET 9 SDK by @nblumhardt in datalust/serilog-sinks-seq#234 * Serilog 4.2 RTM by @KodrAus in datalust/serilog-sinks-seq#237 Commits viewable in [compare view](datalust/serilog-sinks-seq@v8.0.0...v9.1.0). </details> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
See #150
This PR allows an
IFormatProviderto be supplied during the sinks configuration. If supplied the format provider is used to format message tokens.The
PropertiesFormatCorrectlyForTheFormatProvidertest is a reasonable summary of the behavior change.Note that if an
IFormatProvideris specified then the message will be rendered and sent in the payload.