I want to write some kind of debugging tool for my MVC application which is hosted on production hosting environment where I have very limited access and no way to debug the code except like writing each line of code to .txt file. For example let's say I have a code:
public void Foo()
{
var bar = new Bar();
var baz = new Baz();
bar.Qux(baz);
}
What I'm actually doing now is:
public void Foo()
{
MyTxtDebugger.Write("Enter Foo()")
MyTxtDebugger.Write("var bar = new Bar();")
var bar = new Bar();
MyTxtDebugger.Write("var baz = new Baz();")
var baz = new Baz();
MyTxtDebugger.Write("bar.Qux(baz);")
bar.Qux(baz);
MyTxtDebugger.Write("Exit Foo()")
}
Where MyTxtDebugger.Write
is my custom simple text writer. This kind'a does it's thing but I want to make the code much cleaner and do not duplicate the actual code line to a string. What I want to have is this:
public void Foo()
{
[MyTxtDebugger] var bar = new Bar();
[MyTxtDebugger] var baz = new Baz();
[MyTxtDebugger] bar.Qux(baz);
}
Or at least this:
public void Foo()
{
MyTxtDebugger.Write(); var bar = new Bar();
MyTxtDebugger.Write(); var baz = new Baz();
MyTxtDebugger.Write(); bar.Qux(baz);
}
I want the output of MyTxtDebugger.Write()
to be "MyTxtDebugger.Write(); var bar = new Bar();"
. Is this possible and if so, how? I've already studied, for example, this question but in this case the actual C# code is not captured in the output.