ConsoleProxy is a sample logging proxy that can transparently replace any console application and log its usage to a file.
Why it is useful
"As is" it is useful to debug cases when a console proces is invoked from a GUI process behind the scenes: e.g. when
git.exe is invoked from a front end like TortoiseGit or SourceTree. It may also be modified to include additional functionality such as capturing target's output, invoking different versions of the target depending on circumstances, etc.
How to use
To proxy an application named
foo.exe do the following:
- If necessary, remove the original
foo.exefrom PATH and add path to the proxied version instead.
- Create environment variable
NATIVE_fooand set its value to the location of the original
When invoked under name
foo.exe, ConsoleProxy creates a log file under
%localappdata%\ConsoleProxy\Foo folder, locates the original
NATIVE_foo environment variable, and launches it with the same arguments as itself.
For example, suppose the original is located at
c:\program files\foo\foo.exe, and the proxy is
c:\temp\ConsoleProxy\foo.exe. When someone launches
c:\temp\ConsoleProxy\foo.exe -v dostuff
it would invoke the original and create a log file undler
%LOCALAPPDATA%\ConsoleProxy\foo with contents similar to
foo.exe -v dostuff Executing [c:\program files\foo\foo.exe -v dostuff] Exit code 42
If you have questions or comments, feel free to