This library is a replacement for format/3 for printing debug messages. Messages are assigned a topic. By dynamically enabling or disabling topics the user can select desired messages. Debug statements are removed when the code is compiled for optimization.
See manual for details. With XPCE, you can use the call below to start a graphical monitoring tool.
Using the predicate assertion/1 you can make assumptions about your program explicit, trapping the debugger if the condition does not hold.
- debugging(+Topic) is semidet
- debugging(-Topic) is nondet
- debugging(?Topic, ?Bool) is nondet
- Examine debug topics. The form
debugging(+Topic)may be used to perform more complex debugging tasks. A typical usage skeleton is:
( debugging(mytopic) -> <perform debugging actions> ; true ), ...
The other two calls are intended to examine existing and enabled debugging tokens and are typically not used in user programs.
- 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 (atom). This redirects debug information on this topic to the given output.
- debug_topic(+Topic) is det[private]
- Declare a topic for debugging. This can be used to find all topics available for debugging.
- list_debug_topics is det
- List currently known debug topics and their setting.
- debug_message_context(+What) is det
- Specify additional context for debug messages.
- debug(+Topic, +Format, :Args) is det
- Format a message if debug topic is enabled. Similar to format/3
user_error, but only prints if Topic is activated through debug/1. Args is a meta-argument to deal with goal for the @-command. Output is first handed to the hook prolog:debug_print_hook/3. If this fails, Format+Args is translated to text using the message-translation (see print_message/2) for the term
debug(Format, Args)and then printed to every matching destination (controlled by debug/1) using print_message_lines/3.
The message is preceded by '% ' and terminated with a newline.
- prolog:debug_print_hook(+Topic, +Format, +Args) is semidet[multifile]
- Hook called by debug/3. This hook is used by the graphical
frontend that can be activated using prolog_ide/1:
- assertion(:Goal) is det
- Acts similar to C
assert()macro. It has no effect if Goal succeeds. If Goal fails or throws an exception, the following steps are taken:
- call assertion_failed/2. If assertion_failed/2
- If this is an interactive toplevel thread, print a message, the stack-trace, and finally trap the debugger.
- Otherwise, throw
error(assertion_error(Reason, G),_)where Reason is one of
failor the exception raised.
- call assertion_failed/2. If assertion_failed/2 fails, then:
- assume(:Goal) is det[private]
- Acts similar to C
assert()macro. It has no effect of Goal succeeds. If Goal fails it prints a message, a stack-trace and finally traps the debugger.
- prolog:assertion_failed(+Reason, +Goal) is semidet[multifile]
- This hook is called if the Goal of assertion/1 fails. Reason is
unified with either
failif Goal simply failed or an exception call otherwise. If this hook fails, the default behaviour is activated. If the hooks throws an exception it will be propagated into the caller of assertion/1.
The following predicates are exported, but not or incorrectly documented.