0

I have created a custom logger method and fetching the Caller methods methodname and classname in runtime. Will this degrade framework performance? This is selenium framework and always there will be 1 thread accessing.

I tried with and without this method and dint see any issues

public void LogEntry(bool IsTakeScreenShot=false)
{
    var method=new StackTrace().GetFrame(1).GetMethod();
    var methodName = method.Name;
    var className = method.ReflectedType.Name;
    LogMessage(className, methodName, "Entry", IsTakeScreenShot);
}
SSP
  • 85
  • 7
  • 2
    Creating a StackTrace can be expensive. Have a look at the answers here: https://stackoverflow.com/questions/171970/how-can-i-find-the-method-that-called-the-current-method – Sentry Jun 17 '19 at 14:42
  • 1
    See also: [caller information](https://learn.microsoft.com/dotnet/csharp/programming-guide/concepts/caller-information) – Corak Jun 17 '19 at 14:51
  • Thanks. I will consider those.sorry for replaying late – SSP Jun 26 '19 at 10:24

0 Answers0