4 using PostSharp.Aspects;
5 using PostSharp.Aspects.Dependencies;
10 [ProvideAspectRole(
"Logging")]
11 public class Log : OnMethodBoundaryAspect
19 public override void OnEntry(MethodExecutionArgs args)
21 StackFrame frame =
new StackFrame(1,
true);
22 Singleton<Logger>.
Instance.LogInfo($
"Starting {args.Method}", frame.GetMethod().Name, frame.GetFileName(), frame.GetFileLineNumber());
33 public override void OnExit(MethodExecutionArgs args)
36 StackFrame frame =
new StackFrame(1,
true);
37 Singleton<Logger>.
Instance.LogInfo($
"Exit {args.Method}", frame.GetMethod().Name, frame.GetFileName(), frame.GetFileLineNumber());
Class for creating a singleton for a generic class
override void OnExit(MethodExecutionArgs args)
Method executed after the body of methods to which this aspect is applied, even when the method exist...
static T Instance
Gets the instance.
override void OnEntry(MethodExecutionArgs args)
Method executed before the body of methods to which this aspect is applied.