-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TargetWithContext - Easier to capture snapshot of MDLC and NDLC context #2467
Conversation
f3aca6c
to
db25331
Compare
Codecov Report
@@ Coverage Diff @@
## master #2467 +/- ##
========================================
Coverage ? 81%
========================================
Files ? 325
Lines ? 23908
Branches ? 3020
========================================
Hits ? 19380
Misses ? 3713
Partials ? 815 |
5f87959
to
af0aa3e
Compare
An alternative approach would be to implement a different async-target-wrapper using ThreadPool.QueueUserWorkItem (or Tasks). Then the async-state will automatically flow with the LogEventInfo (This will not help MDC + NDC but maybe they are also on their way out). But such async-wrapper will not be able to perform batch-handling, so not that super interesting. And it would also require a new buffering-target-wrapper. |
855dfc2
to
32d3576
Compare
@304NotModified Implementing an easier approach for handling batching of log-events, became too messy. But I like this direction for making it easier for custom targets to make use of MDLC and NDLC without forcing them to use JsonLayout. |
Indeed, that would be a nice improvement! Will try to review the PR this weekend. |
Maybe consider to change the default value of the parameter |
src/NLog/LayoutRenderers/Wrappers/Rot13LayoutRendererWrapper.cs
Outdated
Show resolved
Hide resolved
c90daff
to
6086aa4
Compare
84db6b3
to
7fefb7b
Compare
@304NotModified Now removed the automatic forwarding of properties to the inner-layout, think it was more confusing than helping. |
8e6103a
to
fefb473
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It code looks great!
I tried to implement my own target and tried to understand the properties/method. I proposed some small renames that make things easier (IMO).
/// </summary> | ||
/// <param name="logEvent"></param> | ||
/// <returns>True if properties should be included</returns> | ||
protected bool HasCombinedProperties(LogEventInfo logEvent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proposal to rename (after renames below) -> ShouldIncludeProperties
I prefer removing the term "combined properties", if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
oops sorry for breaking the build edit: can't see what's wrong. Works locally |
740308a
to
669612b
Compare
There is a conflict with my optimizations of the NetworkTarget and this PR. I have now merged with master, and resolved the conflict. |
8cf77b5
to
4574ec3
Compare
4574ec3
to
4717f8f
Compare
4717f8f
to
d2fe890
Compare
merged :) |
Attempt to resolve #2466 and #2465
Guess one could also extend it to enable capture of GDC and Callsite.
Maybe implement a helper method than returns all context properties (IncludeAllProperties, IncludeMdlc, IncludeMdc, IncludeGdc).
Suddenly also become a bugfix for correct precalculation of async data for custom NLog-Layouts. Before it would be impossible for custom NLog-Layouts to correctly capture the async-state. Resolves #254
And a bugfix that allows custom NLog-Layouts to work correctly, when they override Layout.Precalculate and are used with Target.OptimizeBufferReuse = true.