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
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.
···
On Sun, Jun 01, 2003 at 06:38:49AM +0900, Simon Strandgaard wrote:
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.
Thanks Brian.
I have change from Ncurses.initscr into something like this:
@term = Ncurses.newterm("xterm-color", $stdout.dup, $stdin)
Ncurses.set_term(@term)
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