:- module(dbug,[dbug/0,dbug/1,dbug/2,nodbug/0, shouldnt/0, shouldnt/1, shouldnt/2]). :- dynamic dbugging/0. % dbug/0 turns on dbug messages. dbug :- dbugging -> true; assert(dbugging). % dbug(FormatString) defaults the Arguments to []. dbug(FormatString) :- dbug(FormatString,[]). % dbug(FS, Args) prints a message if dbugging is on. dbug(FormatString,Args) :- dbugging -> format(FormatString,Args); true. % nodbug/0 turns off dbug messages. nodbug :- retract(dbugging) -> true; true. % dbugging is off initially. :- nodbug. % shouldnt/0, shouldnt/1, and shouldnt/2 are some simple routines for debugging messages. shouldnt :- format("~nThis shouldnt have happened",[]), fail. shouldnt(String) :- format(String,[]), fail. shouldnt(String,Args) :- format(String,Args), fail.