Scripts/WD Spy

From J Wiki
Jump to navigation Jump to search

WD Spy is a method to trace all wd input and output. It's useful to debug your own wd code, and to learn how other scripts work, such as J Front End itself.

wdtrace_z_=: 3 : 0
  '~temp/log.txt' wdtrace_z_ y
  if. y do.
    log_z_=: [: 1!:3&(<jpath x) ,@:(,&LF"1)@":
    wd_z_=: ([: ([ log) [: 11!:0 ([ log))"1
    wd_z_=: 11!:0
  i.0 0
  • Run the script above
  • Turn on
    wdtrace 1
  • Run wd scripts, e.g. Ctrl+N or Edit|Configure
  • Watch the log file, e.g. temp/log.txt
  • Turn off
    wdtrace 0