From: "Drirr C." Date: 2001-10-02T15:56:31+09:00 Subject: [ruby-talk:21926] Re: Embedding ----- Original Message ----- From: ts > D> Also, I would like to redirect all output (which would come from puts, > D> exceptions, etc... ) to a console. What would be the best way of doing > D> that? > > ruby use $defout to handle #puts, you can perhaps redefine it. > > You must trap the exceptions, otherwise ruby can crash your > application. For example it's best to use rb_eval_string_protect() rather > than rb_eval_string(). Thanks a lot. I didn't know about rb_eval_string_protect(). Now, going back to redirecting the output; the source code is full of printf()'s, fprintf(stderr,...)'s and puts(). For redirecting the output elsewhere I'll need to change most of those functions, if not all. I created a series of macros and functions to use in place of printf and the like. They're not a great thing, but can be useful. I ask the Ruby development team to take a look at them and consider including them in a future release of Ruby, as that might help with the integration of ruby when embedding it. There should be no portability problems. http://www.geocities.com/drirr_cat/ Please let me know what you think about this. Thanks Drirr C. (Guillermo Romero)