Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Has anybody written an AOP Logging Interceptor for a PCL?

$
0
0

I'm looking at adding logging all over my app (for insights), but I really don't want to add all that bloat to the code.

A typical method with logging will look like

public void SomeMethod() {
    _logger.Log(this, "Start");

    try{
        // do stuff
    } catch(Exception ex)
    {
        _logger.Log(this, ex); 
    }
    _logger.Log(this, "End");
}

But my preference would be to decorate it with an interceptor.

[Log("")]
public void SomeMethod(){
    // do stuff
}

I did take a peek at Fody and it might be able to do what I need, but I was hoping for something that didn't necessarily modify the binaries, but instead just intercept the method. Unfortunately I've never done AOP before, so I'm totally new to the paradigm. Also, I wonder if the approach I want without fody would require Reflection.Emit???


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>