Nathan
Nathan

Reputation: 6531

Can I replace SLAB one-method-per-event with types?

Examples for SLAB tend to look like this:

MyCompanyEventSource.Log.ScalingRequestSubmitted(
    request.RoleName, 
    request.InstanceCount,
    context.RuleName,
    context.CurrentInstanceCount);

I don't like that I have to edit MyCompanyEventSource every time I add a new event type. I also don't like that the logger is only available staticly. I'd rather have something like this:

_logger.Log(new ScalingRequestSubmittedEvent(request, context));

I know I can just roll my own logging, but before I dismiss SLAB entirely, I'd like to know if I'm being unfair.

Upvotes: 1

Views: 35

Answers (1)

cassandrad
cassandrad

Reputation: 3536

There is no way to do things like this

_logger.Log(new ScalingRequestSubmittedEvent(request, context));

And you have to change your logger any time you wish to add a new type of event, change information level or keyword.

Writing of your own wrapper for EventSource is the only way to achieve desired functionality.

Upvotes: 2

Related Questions