Implement logging via NpgsqlDataSource#4504
Conversation
| catch (Exception e) | ||
| { | ||
| Logger.LogError(e, $"Exception caught in {nameof(SingleThreadSynchronizationContext)}"); | ||
| Trace.Write($"Exception caught in {nameof(SingleThreadSynchronizationContext)}:" + Environment.NewLine + e); |
There was a problem hiding this comment.
Note this problematic thing - SingleThreadSynchronizationContext is the only place in the codebase where we log from a truly static context, so we can no longer use regular logging there.
We could in theory have a STSC-per-datasource, but this really is a very rare case which has never yet been reported (exception bubbling up) - so it doesn't seem important enough (but let me know if you think otherwise). If we suspect a user is running into it, we can instruct them how to get the message traced here.
There was a problem hiding this comment.
Given that this is really an exceptional case (not part of a normal flow of operations) I don't think it's strange this goes into trace or some named diag source
NinoFloris
left a comment
There was a problem hiding this comment.
LGTM, nice to see it being used in all the tests too!
This is based off of #4492, so only review the latest commit.
Closes #4493