Is there any way I can capture the output of the printfs and then
redirect them to the same file that the trace listener is writing to?
I do have access to the unmanaged C++ code if the solution involves
not using printfs. The important thing is that the C++ printfs and the
C# trace messages end up in the same file.
Thanks
Mitch
If making it a CLR DLL is not an option, you could set a logging facility of
your choosing to be used instead of printf() calls (which is not good design
for a library in any case). The simplest way to do this is to pass a
delegate to C++ to be called whenever logging is necessary. This can be a
little tricky, since passing delegates to be used as function pointers
requires that you be careful about garbage collection. The alternative is to
expose a COM object that will handle logging, and invoke that from C++. This
can be simpler or harder than the delegate solution, depending on how good
you are with COM.
--
J.
Are you saying that if I make it a managed dll, then the output of the
printfs would get picked up by the existing trace listeners in the C#
code? Or would I need to change the printfs to Trace.WriteLine(...)
statements?
Thanks
Mitch
No. Unmanaged code (including printf() calls) would continue to work the same.
> Or would I need to change the printfs to Trace.WriteLine(...) statements?
>
Yes.
--
J.