Avoids running goals to produce output that is only relevant while debugging. Includes pre-canned often used calls.
?- debug( ex ). ?- debug_call( ex, length, '', list1/[x,y,z] ). % Length for list, list1: 3 ?- debug_call( ex, length, 'some prefix', [list1,list2]/[[x,y,z],[a,b,c]] ). % some prefix lengths for lists, list1: 3, list2: 3 ?- debug_call( ex, dims, [m1,m2]/[[a(x),a(y),a(z)],[xy(a,b),xy(c,d),xy(e,f)]] ). % Dimensions for matrices, (m1) nR: 3, nC: 1. (m2) nR: 3, nC: 2. ?- debug_call( ex, wrote, loc(file,csv) ). % Could not locate wrote on file specified by: file, and extensions: csv ?- csv_write_file( 'file.csv', [] ). ?- debug_call( ex, wrote, loc(file,csv) ). % Wrote on file: '/home/nicos/pl/lib/src/trace/file.csv' ?- debug_call( ex, task(stop), 'write on file' ). At 15:44:1 on 2nd of Jul 2014 finished task: write on file.
propose this to be included to debug.pl
debugging(Topic)
succeeds. Else, it is false.
Similar to debugging/2, but does not fail for undefined Topic.
?- debug( something ). true. ?- debugging_status( something, Some ). Some = true. ?- debugging_status( some_else, Else ). Else = false.
?- nodebug( chained ). true. ?- debug( testo ). Warning: testo: no matching debug topic (yet) true. ?- debug( chained, 'debugs chains 1', [] ). true. ?- debug_chain( testo, chained, Prior ). Prior = false. ?- debug( chained, 'debugs chains 2', [] ). % debugs chains 2 true. ?- Prior = false, debug_reset( Prior, chained ). Prior = false. ?- debug( chained, 'debugs chains 3', [] ). true
?- debug_topic( true, example ).
portray_clause(Term)
if we are debugging Topic.
Goal in:
loc(File,Exts)
or simply File in which case Exts = ''.loc(File,Exts)
or simply File in which case Exts = ''.task(Wch)
time of start/stop of a task. Other values are allowed put printed as is. The known values
translate to starting/finshed.call(Goal)
call Goal before printing debugging message.?- debug( ex ). ?- debug_call( ex, length, '', list1/[x,y,z] ). % Length for list, list1: 3 ?- debug_call( ex, length, 'some prefix', [list1,list2]/[[x,y,z],[a,b,c]] ). % some prefix lengths for lists, list1: 3, list2: 3 ?- debug_call( ex, wrote, loc(file,csv) ). % Could not locate wrote on file specified by: file, and extensions: csv ?- csv_write_file( 'file.csv', [] ). ?- debug_call( ex, wrote, loc(file,csv) ). % Wrote on file: '/home/nicos/pl/lib/src/trace/file.csv' ?- debug_call( ex, task(stop), 'write on file' ) % At 15:44:1 on 2nd of Jul 2014 finished task: write on file. ?- debug_call( ex, (length([a,b,c],L),write(len(L)),nl) ). len(3) L = 3.
Goal in:
loc(File,Exts)
or simply File in which case Exts = ''.loc(File,Exts)
or simply File in which case Exts = ''.task(Wch)
time of start/stop of a task. Other values are allowed put printed as is. The known values
translate to starting/finshed.call(Goal)
call Goal before printing debugging message.?- debug( ex ). ?- debug_call( ex, length, '', list1/[x,y,z] ). % Length for list, list1: 3 ?- debug_call( ex, length, 'some prefix', [list1,list2]/[[x,y,z],[a,b,c]] ). % some prefix lengths for lists, list1: 3, list2: 3 ?- debug_call( ex, wrote, loc(file,csv) ). % Could not locate wrote on file specified by: file, and extensions: csv ?- csv_write_file( 'file.csv', [] ). ?- debug_call( ex, wrote, loc(file,csv) ). % Wrote on file: '/home/nicos/pl/lib/src/trace/file.csv' ?- debug_call( ex, task(stop), 'write on file' ) % At 15:44:1 on 2nd of Jul 2014 finished task: write on file. ?- debug_call( ex, (length([a,b,c],L),write(len(L)),nl) ). len(3) L = 3.