%-- __________________________________________________________________________________________ 08-29-2012: new file for debug output includes the following functions: -debug_open(String PLUGIN_NAME, String VERSION) -debug_print(String msg) -debug_println(String msg) -debug_close() ------------------------------------------- Include as follows as first line in plugin: ------------------------------------------- < %@ include file="/plugins/setup/setup.debug.jsp" % > NOTE: ***** LIST ANY FILES THAT INCLUDE THIS FILE BELOW ***** -------------------- Description & Notes: -------------------- Currently only non jsp:includes are supported as shown above. Ultimately code belongs should in RZTagSupport & probably .../util/setup_common_header.jsp Below are list of plugin files that contain a direct include which must be removed when this code is moved and direct include is not required and will throw exception. ----- TODO: ----- 1. Must determine how to input debugOptions: (cannot use session for templates) -perhaps new singleton with HashMap using webspace as key -currently must hardcode debugOptions 2. Pass debug output back to Admin Panel -currently using hidden div on published page ------------------------- Files containing include: ------------------------- 08-29-2012 menus_leftnav_section_filter_include_code.jsp __________________________________________________________________________________________ --%><% //----- Initialize class variables debug_rz = rz; debug_out = out; debug_session = request.getSession(); debug_mode = false; debug_detail = new StringBuffer(); debug_line_buffer = new StringBuffer(); %><%! //----- Declare class variables RZTagSupport debug_rz; JspWriter debug_out; HttpSession debug_session; boolean debug_mode; StringBuffer debug_line_buffer; StringBuffer debug_detail; /** * Called at start of plugin **/ boolean debug_open(String PLUGIN_NAME, String VERSION) throws Exception { debug_mode = false; //----- Get debug options String debugOptions = debug_session.getAttribute("REVIZE_DEBUG_PLUGIN") + ""; ////if (debug_rz.webspace.equals("newnan") && debug_rz.pageid.equals("links-1136")) debug_mode = true; debug_mode = true; debug_println("DEBUG enabled for: " + PLUGIN_NAME + " " + VERSION); return debug_mode; } /** **/ void debug_print(String msg) { if (!debug_mode) return; debug_line_buffer.append(msg); } /** **/ void debug_println(String msg) { if (!debug_mode) return; //convert leading spaces to msg = msg.replaceFirst("^( )*","$1".replaceAll(" "," ")); debug_line_buffer.append(msg); //append to current line debug_line_buffer.append("\n"); //end line debug_detail.append(debug_line_buffer); //append to detail debug_line_buffer = new StringBuffer(); //clear current line } /** * Called at end of plugin to save debug output **/ void debug_close() throws Exception { if (!debug_mode) return; debug_println(""); //flush debug_line_buffer if (debug_detail == null || debug_detail.length() == 0) return; String detail = "
"; debug_out.println(detail); } %>