how to log to my own stream

I would like to change the Logger::log() such that it logs to an ostream that I created myself. From the RTT API, I have learned that this would be possible using Logger::setStdStream (std::ostream& stdos) However, if I use that, the program crashes after a short while of running (0.3 sec, unrelated to periodTime). Can you maybe give a little example of how to accomplish what I want?

Thanks, Theo.

how to log to my own stream

On Mon, Jun 1, 2009 at 23:06, <t [dot] j [dot] a [dot] devries [..] ...> wrote:
> I would like to change the Logger::log() such that it logs to an ostream that I created myself. From the RTT API, I have learned that this would be possible using Logger::setStdStream (std::ostream& stdos) However, if I use that, the program crashes after a short while of running (0.3 sec, unrelated to periodTime). Can you maybe give a little example of how to accomplish what I want?

If you could compile it for gnulinux and provide us a valgrind trace,
we might have a quicker idea of what the problem is...

Peter

Re: how to log to my own stream

peter wrote:

On Mon, Jun 1, 2009 at 23:06, <t [dot] j [dot] a [dot] devries [..] ...> wrote:
> I would like to change the Logger::log() such that it logs to an ostream that I created myself. From the RTT API, I have learned that this would be possible using Logger::setStdStream (std::ostream& stdos) However, if I use that, the program crashes after a short while of running (0.3 sec, unrelated to periodTime). Can you maybe give a little example of how to accomplish what I want?

If you could compile it for gnulinux and provide us a valgrind trace,
we might have a quicker idea of what the problem is...

Peter

Thanks for the offer to help.
I tried your suggestion. Basically, I think the problem is not in RTT; if I use Orocos alone, it just works as expected.
I wanted to have the Logger output redirected to a wxWidgets Text Control. Whenever I combine redirection functionality of wxWidgets with Logger output, the program crashes. The valgrind output just says segmentation fault (but then again, I have never used valgrind before). Haven't got a clue what to do to resolve the problem...

Cheers, Theo.

how to log to my own stream

On Wed, Jun 3, 2009 at 23:31, <t [dot] j [dot] a [dot] devries [..] ...> wrote:
>

peter wrote:
On Mon, Jun 1, 2009 at 23:06,  <t [dot] j [dot] a [dot] devries [..] ...> wrote:
>> I would like to change the Logger::log() such that it logs to an ostream that I created myself. From the RTT API, I have learned that this would be possible using Logger::setStdStream (std::ostream& stdos) However, if I use that, the program crashes after a short while of running (0.3 sec, unrelated to periodTime). Can you maybe give a little example of how to accomplish what I want?
>
> If you could compile it for gnulinux and provide us a valgrind trace,
> we might have a quicker idea of what the problem is...
>
> Peter
>

>
> Thanks for the offer to help.
> I tried your suggestion. Basically, I think the problem is not in RTT; if I use Orocos alone, it just works as expected.
> I wanted to have the Logger output redirected to a wxWidgets Text Control. Whenever I combine redirection functionality of wxWidgets with Logger output, the program crashes. The valgrind output just says segmentation fault (but then again, I have never used valgrind before). Haven't got a clue what to do to resolve the problem...

The problem you're probably facing is a multi-threading issue. You are
probably not allowed to write to a wxWidget from another thread in
your application. It's a common issue with GUI libraries.

There is an alternative: from your wxWidget, use the
log().getLogLine() to read one line at a time. if it returns the
empty string, no new messages are available. I used it in the
ktaskbrowser gui as well.

Peter

Ok, Peter, that works well,

Ok, Peter, that works well, thanks!
Now that I have it running, a request comes up. I would like to get lines up to a certain LogLevel. Unlike what I expected, it appeared that setLogLevel has no effect on getLogLine(). That's fine, but it would be nice then if I could selectively get messages with getLogLine(LogLevel), where the default argument is Info, so that we are backwards compatible.
If I submit a patch, would it be included?

Thanks again, Theo

Ok, Peter, that works well,

On Thu, Jun 4, 2009 at 20:09, <t [dot] j [dot] a [dot] devries [..] ...> wrote:
> Ok, Peter, that works well, thanks!
> Now that I have it running, a request comes up. I would like to get lines up to a certain LogLevel. Unlike what I expected, it appeared that setLogLevel has no effect on getLogLine(). That's fine, but it would be nice then if I could selectively get messages with getLogLine(LogLevel), where the default argument is Info, so that we are backwards compatible.
> If I submit a patch, would it be included?

Yes, but you need to define the getLogLine(LogLevel) as a second
function, *not* with a default argument.
Otherwise we won't be binary compatible.

Peter