Open stachu99 opened 1 year ago
Hey @stachu99, yes, I've always thought the diagnostics system needs some improvements as well. This is something we can improve.
- In this option still lose CppSharp.Utils.FSM.ConsoleWriter message type.
This was something we imported from some other code, so we can get rid of it no problem.
I thing that the best option would be using CppSharp.Diagnostics for all messages generated by CppSharp and definitively avoid using Console.Write/WriteLine.
I think so too, we can definitely do this and seems like the simplest option. I don't like too much a library redirecting the standard output and error streams.
Please, could you provide some worked code to redirect native stdout\stderr or any clue how do this?
I don't really have any working code for this at this time, but I can improve the current codebase so everything goes through Diagnostics
or similar API. At the moment the priority is to finish the upgrade to Clang 16, after that is done I can improve the diagnostics.
Thanks tritao.
In the CppSharp solution is used many various ways to produce messages/logs like CppSharp.Diagnostics, Console.WriteLine, native stdout\stderr (printf), CppSharp.Utils.FSM.ConsoleWriter. Finally all messages are listed at the Console and it's fine. What if I would like to implement own logging solution. I have options: a. The simplest way is run own CppSharp solution as a Process and redirect stdout\stderr, with losted details like:
b. Implement CppSharp.Diagnostics.IDiagnostics, redirect Console stdout\stderr and redirect native stdout\stderr (printf). In this option still lose CppSharp.Utils.FSM.ConsoleWriter message type. If is implemented a Console stdout\stderr redirection to own logging implementation and this implementation sinks loggs to Console there has made a loop.
I thing that the best option would be using CppSharp.Diagnostics for all messages generated by CppSharp and definitively avoid using Console.Write/WriteLine.
CppSharp.Utils.FSM.ConsoleWriter replacing with CppSharp.Diagnostics.
Personally, I use CppSharp to generate C++/CLI and CSharp code so do not use classes with references to CppSharp.Utils.FSM.ConsoleWriter.
Is there possibility to get more diagnostic logs like errors/warnings from clang compiler at parsing and semantic analysis stages. Similarly to produced output of command 'clang.exe -Xclang -fsyntax-only'.
I have got an issue to catch native stdout\stderr (printf). I use DriverOptions.Verbose turned on and some diagnostic messages are listed at the Console, e.g. compiler arguments, Target triple, includes. I have tried redirecting stdout\stderr to a file or to an AnonymousPipeServerStream using SetStdHandle() method from kernel32.dll and it failed. The file/stream is always empty and all messages are listed at the console. There is a part of code:
The file is created and there is none messages. Please, could you provide some worked code to redirect native stdout\stderr or any clue how do this? I would like to avoid to run my CppSharp implementation as a nested Process and redirect the process stdout\stderr.
Best regards, Stachu99