Not sure whether this does match your request and also whether it is a good idea for production.
Anyway maybe you try it and get some ideas.
Use System.Runtime.CompilerServices for this:
using System.Runtime.CompilerServices;
namespace LogTests
{
public static class LogTest
{
public static string Log(string infoText,
[CallerFilePath] string file = "",
[CallerMemberName] string member = "",
[CallerLineNumber] int line = 0)
{
string test = string.Format("File= {0} Member= {1} Line= {2} InfoText= {3}", file, member, line, infoText);
return (test);
}
}
}
MyControl has do do something like this:
namespace MyControls
{
public class MyControl
{
private void PathTest()
{
string test = LogTest.Log("MyControl");
}
}
}
I hope it helps.