Simply3DScan
Log.cs
Go to the documentation of this file.
1 using System;
2 using System.Diagnostics;
3 using Logging;
4 using PostSharp.Aspects;
5 using PostSharp.Aspects.Dependencies;
6 
7 namespace SharedObjects
8 {
9  [Serializable]
10  [ProvideAspectRole("Logging")]
11  public class Log : OnMethodBoundaryAspect
12  {
19  public override void OnEntry(MethodExecutionArgs args)
20  {
21  StackFrame frame = new StackFrame(1,true);
22  Singleton<Logger>.Instance.LogInfo($"Starting {args.Method}", frame.GetMethod().Name, frame.GetFileName(), frame.GetFileLineNumber());
23  base.OnEntry(args);
24  }
25 
33  public override void OnExit(MethodExecutionArgs args)
34  {
35 
36  StackFrame frame = new StackFrame(1, true);
37  Singleton<Logger>.Instance.LogInfo($"Exit {args.Method}", frame.GetMethod().Name, frame.GetFileName(), frame.GetFileLineNumber());
38  base.OnExit(args);
39  }
40  }
41 }
Class for creating a singleton for a generic class
Definition: Singleton.cs:9
override void OnExit(MethodExecutionArgs args)
Method executed after the body of methods to which this aspect is applied, even when the method exist...
Definition: Log.cs:33
Definition: Logger.cs:5
static T Instance
Gets the instance.
Definition: Singleton.cs:27
override void OnEntry(MethodExecutionArgs args)
Method executed before the body of methods to which this aspect is applied.
Definition: Log.cs:19