ncurses + redirect output 
Author Message
 ncurses + redirect output

I am having a hard time debugging my ncurses code...
Some advices for improving debugging would be nice.

STORY: ncurses output goes to $stdout.
if an error happens in the ruby code, then backtrace is written to
$stdout.

PROBLEM: I cannot see this backtrace.. and I would really like to see what
went wrong, so it can be fixed.

If I $stdout.reopen(File.new("log", "w+")), then all ncurses output goes
to the file too. The error-message is drowning in ansi-escape-sequences.

How do I seperate Ncurses output from Ruby output ?

--
Simon Strandgaard



Thu, 17 Nov 2005 05:23:13 GMT  
 ncurses + redirect output

Quote:

> STORY: ncurses output goes to $stdout.
> if an error happens in the ruby code, then backtrace is written to
> $stdout.

> PROBLEM: I cannot see this backtrace.. and I would really like to see what
> went wrong, so it can be fixed.

I think such things are normally written to stderr, so you should be able to
do $stderr.reopen instead.

Otherwise, you can always do:

  errfile = File.open("log","a")
  begin
    run_my_ruby_code
  rescue Exception
    errfile.puts "Error: #{$!}\nBacktrace: #{$!.backtrace}"
  end

Regards,

Brian.



Thu, 17 Nov 2005 06:07:33 GMT  
 ncurses + redirect output
Thanks Brian.

I have change from Ncurses.initscr into something like this:



        fd = File.new("log", "w+")
        $defout.reopen(fd)
        $stdout.reopen(fd)
        $stderr.reopen(fd)

This seperates Ruby output from Ncurses output.

Unfortunatly this hack makes Ncurses behaving strange,
suddenly Ncurses output just stops ?  I have to investigate this further.

--
Simon Strandgaard



Thu, 17 Nov 2005 07:17:58 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. help with ncurses - if anyone can give me a simple ncurses program

2. Help redirecting output from spawned process

3. Why when redirect output, it doesn;t work????

4. VSE - Redirect Standard input/output

5. Redirecting Output to files

6. Redirecting to TWO output files

7. redirecting print output to variable name in awk

8. Redirecting program output to file

9. how to redirect lpt1 to file-output

10. Redirecting output (ISE)

11. Redirecting output from GNU C++ compiler under MSDOS

12. Redirecting Output?

 

 
Powered by phpBB® Forum Software