Did you know ... Search Documentation:
Pack log4p -- prolog/log4p.pl
PublicShow source

Re-exported predicates

The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.

 debug(+Topic) is det
 nodebug(+Topic) is det
Add/remove a topic from being printed. nodebug(_) removes all topics. Gives a warning if the topic is not defined unless it is used from a directive. The latter allows placing debug topics at the start of a (load-)file without warnings.

For debug/1, Topic can be a term Topic > Out, where Out is either a stream or stream-alias or a filename (an atom). This redirects debug information on this topic to the given output. On Linux systems redirection can be used to make the message appear, even if the user_error stream is redefined using

?- debug(Topic > '/proc/self/fd/2').

A platform independent way to get debug messages in the current console (for example, a swipl-win window, or login using ssh to Prolog running an SSH server from the libssh pack) is to use:

?- stream_property(S, alias(user_error)),
   debug(Topic > S).

Do not forget to disable the debugging using nodebug/1 before quitting the console if Prolog must remain running.

 trace(:Pred) is det
 trace(:Pred, +PortSpec) is det
Print passes through ports of specified predicates. Pred is a, possible partial, specification of a predicate as it is also used be spy/1 and similar predicates. Where a full predicate specification is of the shape Module:Name/Arity (or `//Arity for non-terminals), both the module and arity may be omitted in which case Pred refers to all matching predicates. PortSpec is either a single port (call, exit, fail or redo), preceded with + or - or a list of these. The predicate modifies the current trace specification and then installs a suitable wrapper for the predicate using wrap_predicate/4. For example:
?- trace(append).
%     lists:append/2: [all]
%     lists:append/3: [all]
%     append/1: [all]
true.

?- append([a,b], [c], L).
 T [10] Call: lists:append([a, b], [c], _18032)
 T [19] Call: lists:append([b], [c], _19410)
 T [28] Call: lists:append([], [c], _20400)
 T [28 +0.1ms] Exit: lists:append([], [c], [c])
 T [19 +0.2ms] Exit: lists:append([b], [c], [b, c])
 T [10 +0.5ms] Exit: lists:append([a, b], [c], [a, b, c])
L = [a, b, c].

?- trace(append, -all).
%     lists:append/2: Not tracing
%     lists:append/3: Not tracing
%     append/1: Not tracing

The text between [] indicates the call depth (first number) and for all ports except the call port the wall time since the start (call port) in milliseconds. Note that the instrumentation and print time is included in the time. In the example above the actual time is about 0.00001ms on todays hardware.

In addition, conditions may be specified. In this case the the specification takes the shape trace(:Head, Port(Condition)). For example:

?- trace(current_prolog_flag(Flag, Value), call(var(Flag))).
?- list_tracing.
% Trace points (see trace/1,2) on:
%     system:current_prolog_flag(A,_): [call(var(A))]

This specification will only print the goal if the registered condition succeeds. Note that we can use the condition for its side effect and then fail to avoid printing the event. Clearing the trace event on all relevant ports removes the condition. There is currently no way to modify the condition without clearing the trace point first.

 trace(:Pred) is det
 trace(:Pred, +PortSpec) is det
Print passes through ports of specified predicates. Pred is a, possible partial, specification of a predicate as it is also used be spy/1 and similar predicates. Where a full predicate specification is of the shape Module:Name/Arity (or `//Arity for non-terminals), both the module and arity may be omitted in which case Pred refers to all matching predicates. PortSpec is either a single port (call, exit, fail or redo), preceded with + or - or a list of these. The predicate modifies the current trace specification and then installs a suitable wrapper for the predicate using wrap_predicate/4. For example:
?- trace(append).
%     lists:append/2: [all]
%     lists:append/3: [all]
%     append/1: [all]
true.

?- append([a,b], [c], L).
 T [10] Call: lists:append([a, b], [c], _18032)
 T [19] Call: lists:append([b], [c], _19410)
 T [28] Call: lists:append([], [c], _20400)
 T [28 +0.1ms] Exit: lists:append([], [c], [c])
 T [19 +0.2ms] Exit: lists:append([b], [c], [b, c])
 T [10 +0.5ms] Exit: lists:append([a, b], [c], [a, b, c])
L = [a, b, c].

?- trace(append, -all).
%     lists:append/2: Not tracing
%     lists:append/3: Not tracing
%     append/1: Not tracing

The text between [] indicates the call depth (first number) and for all ports except the call port the wall time since the start (call port) in milliseconds. Note that the instrumentation and print time is included in the time. In the example above the actual time is about 0.00001ms on todays hardware.

In addition, conditions may be specified. In this case the the specification takes the shape trace(:Head, Port(Condition)). For example:

?- trace(current_prolog_flag(Flag, Value), call(var(Flag))).
?- list_tracing.
% Trace points (see trace/1,2) on:
%     system:current_prolog_flag(A,_): [call(var(A))]

This specification will only print the goal if the registered condition succeeds. Note that we can use the condition for its side effect and then fail to avoid printing the event. Clearing the trace event on all relevant ports removes the condition. There is currently no way to modify the condition without clearing the trace point first.

 sin(+Angle, -Sine) is det
 cos(+Angle, -Cosine) is det
 tan(+Angle, -Tangent) is det
 log(+X, -NatLog) is det
 log10(+X, -Log) is det
 pow(+X, +Y, -Pow) is det
 ceiling(+X, -Value) is det
 floor(+X, -Value) is det
 round(+X, -Value) is det
 sqrt(+X, -Value) is det
 acos(+X, -Value) is det
 asin(+X, -Value) is det
 atan(+X, -Value) is det
 atan2(+Y, +X, -Value) is det
 sign(+X, -Value) is det
Math library predicates. SWI-Prolog (and ISO) support these as functions under is/2, etc.
deprecated
- Do not use these predicates except for compatibility reasons.
Compatibility
- Quintus Prolog.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 fatal(Arg1)
 error(Arg1)
 warn(Arg1)
 info(Arg1)
 fatal(Arg1, Arg2)
 error(Arg1, Arg2)
 warn(Arg1, Arg2)
 info(Arg1, Arg2)
 debug(Arg1, Arg2)
 get_log_level(Arg1)
 set_global_log_level(Arg1)
 set_global_log_level(Arg1, Arg2)
 clear_global_log_level
 set_local_log_level(Arg1)
 set_local_log_level(Arg1, Arg2)
 clear_local_log_level
 log_levels(Arg1)
 add_log_handler(Arg1)
 remove_log_handler(Arg1)
 stderr_log_handler(Arg1, Arg2)
 use_default_log_handler
 use_stderr_log_handler
 logf(Arg1, Arg2, Arg3)