!7 // TODO: capture all of System.out/System.err cmodule SystemPrintLog { int linesToShow = 100, interval = 250; transient Appendable log; // virtual NotifyingStringBuffer transient JFastLogView_noWrap view; transient long changesSeen; start { if (dm_getBounds() == null) dm_setBounds(this, 0, max(0, getHeight(dm_desktopPane())-200), 400, 200); log = getCreator('print_log); doEvery(interval, r updateMe); } visualize { ret componentPopupMenuItems(jSection("SYSTEM LOG", view = swingNu(JFastLogView_noWrap, str(log))), "Clear", r { clearStringBuffer_gen(log) }, "Copy to new window", r { showText("System Log", log) }); } void unvisualize { ta = null; } void update { JFastLogView_noWrap _view = view; if (_view == null) ret; Long changes = cast getOpt(log, 'changes); if (changes == null || neq(changes, changesSeen)) { if (changes != null) changesSeen = changes; _view.setText(extractLastNLinesOfString(linesToShow, str(log))); } } }