Re: capturing print_message to a file
Alan Baljeu <[email protected]> Thu, 3 Apr 2014 08:49:25 -0700 (PDT)
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
Thanks for the example below. I was aware of these methods, but after reading documentation I didn't understand how to use them. ---------------------- In fact, you can also redirect user_error. Boils down to this: current_error(Stream) :- stream_property(Stream, alias(user_error)), !. % force det. set_error(Stream) :- set_stream(Stream, alias(user_error)). Now, you can do this: :- meta_predicate redirect_error(0, +). redirect_error(Goal, File) :- current_error(OldErr), setup_call_cleanup( open(File, write, Err), setup_call_cleanup( set_error(Err), once(Goal), set_error(OldErr)), close(Err)). -------------- next part -------------- HTML attachment scrubbed and removed