print_message_lines/3print_message_lines(+Stream, +Prefix, +Lines)
Print the Lines to Stream, preceding each line with
Prefix. Note that print_message_lines/3 only succeeds if
Lines is a list of pair.
[Line1, Line2, ...], where each
Linei is of the form
[Control_1-Args_1,Control_2-Args_2, ...].
This command is intended to
be used in conjunction with message_hook/3. After a message is
intercepted using message_hook/3, this command is used to print
the lines. If the hook has not been defined, the arguments are those
provided by the system.
print_message_lines/3 is a simple failure driven loop over the
Lines data structure, implemented as:
:-use_module(library(basics),[member/2]).
print_message_lines(Stream,Prefix,Lines):-
member(Line,Lines),
format(Stream,'~N~w',[Prefix]),
( member(C-A,Line),
format(Stream,C,A)
; nl(Stream)
),
fail.
print_message_lines(_,_,_).
Any exception that format/3 might raise.
A typical use of this would be when using the
user defined predicate, message_hook/3 to redirect output. For
example:
message_hook(_,_,Lines):-
my_stream(MyStream),
print_message_lines(MyStream,'',Lines).
message_hook/3, print_message/2, generate_message/3, query_hook/6