## debug.pkg
## Author: Stefan Westmeier (Last modification by $Author: 2cxl $)
## (C) 1996, Bremen Institute for Safe Systems, Universitaet Bremen
# Compiled by:
#
src/lib/tk/src/tk.sublib# **************************************************************************
# Package for debugging output.
# **************************************************************************
package debug
: (weak) Debug # Debug is from
src/lib/tk/src/debug.api{
include package basic_utilities;
all = [0];
debugs = REF ([]:List( Int ));
fun one_on 0 => debugs := all;
one_on l => debugs := l . *debugs;
end;
fun one_off 0 => debugs := [];
one_off l => debugs := list::filter (not o (eq l)) *debugs;
end;
on = apply one_on;
off = apply one_off;
fun print l s
=
if (*debugs == all or (list::exists (eq l) *debugs))
file::write (file::stderr, s$"\n");
fi;
warn_me = REF TRUE;
fun warning msg =
if *warn_me file::write (file::stderr, "WARNING: " + msg + "\n");
fi;
fun warn_on () = warn_me := TRUE;
fun warn_off () = warn_me := FALSE;
fun error msg
=
file::write (file::stderr, "ERROR: " + msg + "\n");
};