Simply3DScan
LogException.cs
Go to the documentation of this file.
1 using System;
2 using System.Diagnostics;
3 using Logging;
4 using PostSharp.Aspects;
5 
6 namespace SharedObjects
7 {
8  [Serializable]
9  public class LogException : OnExceptionAspect
10  {
16  public override void OnException(MethodExecutionArgs args)
17  {
18  Arguments arguments = args.Arguments;
19 
20  StackTrace st = new StackTrace(args.Exception, true);
21  StackFrame frame = st.GetFrame(0);
22 
23  Singleton<Logger>.Instance.LogWarning(String.Format("Call to {0} failed", args.Method.Name));
24  foreach (object argument in arguments)
25  Singleton<Logger>.Instance.LogWarning(String.Format("Argument: {0}", argument));
26 
27 
28  Singleton<Logger>.Instance.LogException(args.Exception, args.Method.Name, frame.GetFileName(), frame.GetFileLineNumber());
29  args.FlowBehavior = FlowBehavior.Continue;
30  base.OnException(args);
31  }
32  }
33 }
Class for creating a singleton for a generic class
Definition: Singleton.cs:9
Definition: Logger.cs:5
override void OnException(MethodExecutionArgs args)
Method executed after the body of methods to which this aspect is applied, in case that the method re...
Definition: LogException.cs:16
static T Instance
Gets the instance.
Definition: Singleton.cs:27