jonwagner / EventSourceProxy

EventSourceProxy (ESP) is the easiest way to add scalable Event Tracing for Windows (ETW) logging to your .NET program
Other
97 stars 20 forks source link

Static Fields? #32

Closed Mike-E-angelo closed 9 years ago

Mike-E-angelo commented 9 years ago

I'm looking at this line here: https://github.com/jonwagner/EventSourceProxy/blob/master/EventSourceProxy/TracingProxyImplementer.cs#L161

Just curious on why this and the next 2 likes (3 fields total) get created as static members. Shouldn't they be instance-members? If an implementer is using IoC with per-request (non-singleton) implementation, then the 2nd time this gets called, the _log field will be overwritten. I may have this completely misunderstood, however.

jonwagner commented 9 years ago

The ETW/EventSource framework requires that there is exactly one EventSource object for a given stream. So, you're forced to use a singleton.

I'm pretty sure that the rest of the code enforces the singleton behavior. For a non-EventSource implementation, I'd probably do it a different way.

Mike-E-angelo commented 9 years ago

Yeah... I see why now. That EventSource is just a wrapper around the kernel object, of which there is only one. Cool, thanks!