by fleabitdev · 2y ago · 0 comments
The killer feature is that you can shadow a dynamic variable, changing its value for the duration of a dynamic scope, in the same way that an inner `catch` handler overrides an outer one.
For example, you could have a dynamic variable which tells the `print` function where to send its text output. The variable's value would probably default to stdout. By temporarily assigning a string-stream to that variable, you could collect an arbitrary function's text output into a string instead. Regardless of where the text is going, any function which produces text could still use the convenient global `print` function.
Of course, no compile-time checking there, so the combination sounds indeed quite useful.
https://github.com/serilog/serilog/wiki/Enrichment#the-logco...