public class LoggerInterceptor : IInterceptor | |
{ | |
public void Intercept(IInvocation invocation) | |
{ | |
var logger = invocation.Request.Context.Kernel.Get<Logger>(); | |
logger.Trace(string.Format("Start method {0} with {1}", invocation.Request.Method.Name, ArgumentsToString(invocation.Request.Arguments))); | |
invocation.Proceed(); | |
logger.Trace(string.Format("End method {0} with {1}", invocation.Request.Method.Name, invocation.ReturnValue.ToString())); | |
} | |
private string ArgumentsToString(object[] arguments) | |
{ | |
var builder = new StringBuilder(); | |
for (int i=0; i<arguments.Length; i++) | |
{ | |
builder.Append(string.Format("Arg[{1}]={0},", arguments[i].ToString(), i)); | |
} | |
return builder.ToString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment