Re: capturing print_message to a file
Alan Baljeu <[email protected]> Thu, 3 Apr 2014 07:13:23 -0700 (PDT)
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
This module I couldn't find (6.4.1):
65 ?- check_installation:run_collect_messages(cp:test_member_con_instance, Result, Messages).
ERROR: [Thread 2] toplevel: Undefined procedure: check_installation:run_collect_messages/3 (DWIM could not correct goal)
[debug] 67 ?- [library(check_installation)].
ERROR: [Thread 2] source_sink `library(check_installation)' does not exist
The code exhibits an interesting use of asserta to make a temporary
hook.
The predicate would be nice to have documented and in a public
module not related to installation.
Anyway by now I have put together similar:
%% the main thing is I dump to stdout so I can redirect it.
user:message_hook(_Message, trace, Lines) :- maplist(spew, Lines).
spew(flush) :- !,nl.
spew(X) :- atom(X), !, write(X).
spew(X-Y) :- format(X, Y).
spew(X) :- format('Unknown: ~w', [X]).
%% turn on trace and redirect it:
:- meta_predicate chr_trace_log(:).
chr_trace_log(Method) :-
once(chr_leash(none))
, setup_call_cleanup((chr_trace
, debug
, tell('chr_trace.log'))
, Method
, (flush
, told
, chr_notrace)).
Alan Baljeu
----- Original Message -----
From: Jan Wielemaker <[email protected]>
To: Alan Baljeu <[email protected]>; Prolog <[email protected]>
Cc:
Sent: Thursday, April 3, 2014 3:50:26 AM
Subject: Re: [SWIPL] capturing print_message to a file
On 04/02/2014 10:26 PM, Alan Baljeu wrote:
> I see all this stuff flying by onscreen, so I want a file. It's not
> stdout so I guess it's stderr. Is redirecting the stream the
> intended way to go, or is the message_hook stuff the way to go?
Maybe this:
http://www.swi-prolog.org/pldoc/doc/home/vnc/prolog/lib/swipl/library/check_installation.pl?show=src#run_collect_messages/3
Cheers --- Jan
>
> Alan Baljeu -------------- next part -------------- HTML attachment
> scrubbed and removed _______________________________________________
> SWI-Prolog mailing list [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>
-------------- next part --------------
HTML attachment scrubbed and removed