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

Enum type ToString in TraceParameterProvider #33

Closed megakid closed 9 years ago

megakid commented 9 years ago

Hi there,

I have been logging my events using an interface that EventSourceProxy enables. E.g.

[EventSourceImplementation(Name = "MySource")]
public interface IEventSource
{
    [Event(1, Level = EventLevel.Informational)]
    void LogItServiceStatusEvent(string itService, RagStatus status);
 }

This works fine but the event has 'status' = 0, 1, 2 etc... corresponding to the enum value. I want to print the name of the enum value instead. Following the documentation, I added this line before any proxies are created:

            TraceParameterProvider.Default.ForAnything()
                .With<RagStatus>().Trace(e => e.ToString()).As("status");

Now I get this error when creating my proxy:

A first chance exception of type 'System.InvalidOperationException' occurred in EventSourceProxy.dll

Additional information: Cannot convert type ChamMon.Model.RagStatus to a type compatible with EventSource

My other remapped properties work fine. Is there another way of achieving my goal?

Cheers,

James

jonwagner commented 9 years ago

That could be a bug.

Have you tried it without the As clause at the end?

jonwagner commented 9 years ago

This is fixed in v3.0.4. For my tests, I configured it as:

TraceParameterProvider.Default.ForAnything().Trace((RagStatus s) => s.ToString());