Created
June 19, 2017 20:59
-
-
Save yaplex/0a2ce9c34278f80a3f0cb56152b42ec0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void Intercept(IInvocation invocation) | |
| { | |
| var logger = LogManager.GetLogger(invocation.TargetType); | |
| try | |
| { | |
| StringBuilder sb = null; | |
| if (logger.IsDebugEnabled) | |
| { | |
| sb = new StringBuilder(invocation.TargetType.FullName) | |
| .Append(".") | |
| .Append(invocation.Method) | |
| .Append("("); | |
| for (int i = 0; i < invocation.Arguments.Length; i++) | |
| { | |
| if (i > 0) | |
| sb.Append(", "); | |
| sb.Append(invocation.Arguments[i]); | |
| } | |
| sb.Append(")"); | |
| logger.Debug(sb); | |
| } | |
| invocation.Proceed(); | |
| if (logger.IsDebugEnabled) | |
| { | |
| logger.Debug("Result of " + sb + " is: " + invocation.ReturnValue); | |
| } | |
| } | |
| catch (Exception e) | |
| { | |
| logger.Error(e); | |
| throw; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment