Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Redirect output of a currently debugged program to the logmanager
(1/1)
MaSydJun:
Unfortunately in Codeblocks i didn't yet find a possibility to redirect a programs' output to a seperate tab in the "Logs & others" section.
Well I know, that exact same job. But i can't use them when debugging a program. Also, I find it more convinient to just press the run-/debug-button and the output will automatically displayed in an logger window.
So I decided to simply write a plugin.
I already managed to write a message to a seperate, self-created logging-window in the "Logs & others" section, when the user presses the "debug" button (or presses [F8]).
For this purpose I read the source code of the Valgrind-plugin, which was quite straight forward.
But now I'm stuck. I don't know how to redirect the output of the program to this logging-window.
Does anyone know how to fetch the output and redirect it?
Another question, which is not related to my problem above:
As I created a new logging window in the plugin I wrote, it was very tricky to find a "free slot".
--- Code: ---Manager::Get()->GetLogManager()->Slot(i);
--- End code ---
whereas i is the so called tab-index.
But i could just guess at which index i want to place my new logging-window and which slot is free.
Well, the first 3 indices (1, 2, 3) are already used. But all others are more or less "unknown".
I used the following piece of code to get the first free slot:
--- Code: --- logman = Manager::Get()->GetLogManager();
// ...
for (int i = 0; i < logman->ListAvailable().size(); i++)
// check for g_null_log to indicate a free slot
if (logman->Slot(i).GetLogger() != &g_null_log)
{
free_slot_index = i;
break;
}
--- End code ---
Now my question: Is there an easier way to do this. Cause the solution above is just a dirty hack, but it works ;)
Regards
oBFusCATed:
--- Quote from: MaSydJun on September 12, 2013, 10:38:16 pm ---Does anyone know how to fetch the output and redirect it?
--- End quote ---
What OS?
--- Quote from: MaSydJun on September 12, 2013, 10:38:16 pm ---Now my question: Is there an easier way to do this. Cause the solution above is just a dirty hack, but it works ;)
--- End quote ---
There is a proper API for this. See cbEVT_ADD_LOG_WINDOW, cbEVT_REMOVE_LOG_WINDOW and other related events.
MaSydJun:
I Use GNU/Linux.
Actually I'm already using the cbEVT_ADD_LOG_WINDOW event.
I guess I didn't really get the point of it, because how do I determine the tab-index of the logging-window, that was createt by processing the event.
I'll research that ;)
EDIT:
Damn, it's much easier than I thought it would be...
By processing the event everything is already done. I just have to use the given logger-instance that I passed to the constructor of the CodeBlocksLogEvent-class.
------------------------------------------------
EDIT:
I guess I found something interesting: cbEVT_PIPEDPROCESS_STDOUT
Could this be able with the PipedProcess-class?
How do I get the output of the debugged program?
Navigation
[0] Message Index
Go to full version