Debug Info v2.5
Debug Info is a VBScript class useful for developing and debugging ASP web pages. By placing 3 lines of code in the top of every page (or include in your header include file) you can see some of what is going on on each of your pages (displayed at the end of the page). You can also alter QueryString, Form, Session, Application and Cookie information on the fly. When you deploy the application you don't have to go through all your pages and comment out or remove all your debug information. Just comment out 1 line of code or only initialise the class depending on the login rights of your user (if applicable) and your debug data is no longer shown.
This code is based on an example from Microsoft which "Mike" built. Mike added some great formatting which I have enhanced and then added a lot of extra functionality to. See History below for more info. I have also added some routines based on work from Martin Krolik.
Debug Info will display
many types of information
in separate expandable / collapsible bars.
Bars with bold caption text contain data in their
hidden pane; click on the
bar to expand / collapse the
information pane within it. The panes available are:
Summary Info Date/time, build time, request type & status,
scripting engine
Variables Your custom variables
QueryString
Form
Cookies including sub keys
Session Locale, code page and session ID
Application
Server Variables including Time out
JavaScript / DOM Basic DOM browser with javascript execute window
(debugger)
Database Info ADO and DBMS info
Session Static Objects
Application Static Objects
Usage
Include the file in the top of your asp page like this...
<!--#Include File="clsDebug.asp"-->
<%
Create the debug object:
Dim DebugInfo
Set DebugInfo = New clsDebug
See DebugDemo.asp for a full demonstration!
Note: ASP.NET has it's own debugging mode and trace system. You only need to use this code for ASP 2 and 3.
Functionality
When running, a 2 tone blue expandable / collapsible table/panel is visible at the bottom of the screen. Click on the headers to expand or collapse each section.
Clicking the X next to the "Debug Information" label will hide the whole table - a page refresh is required to show it again.
Only items with a darker blue box around the value are editable. Press Save Updates or Re-post to save only that section.
All 3 lines of code can be placed together in the footer if need be. The only reason the class is created at the top of the page is to time the building of the page.
The debug panel is displayed when the class is terminated or you call. This happens when the page code is finished running or you place this in your code: Set DebugInfo = Nothing or DebugInfo.Display
Methods
GrabDatabaseInfo Connection Object
Obtains the required information from your database connection.
Connection Object is an existing object initialised from Server.CreateObject("ADODB.Connection")Print "label", value
"label", is a descriptive text string to be displayed in the debug pane.
value, is the value of that variable.
When used within an error trap "on error..." the resulting error will be displayed in place of the value passed.Display
Display the debug panel now. You do not need to call this as you can simply destroy the class (Set DebugInfo = Nothing ) which will call Display anyway.
If Enabled has been set to False, then this method will do nothing.
Calling this method will set Enabled to False after it is displayed. This is so that when the class is destroyed it does not display a second time.
Properties
ClassFile = "/path/file.asp"
Virtual path and file name of the class. Required for editing of non-repost collections.
Default is "clsDebug.asp"Editing = True | False
Allows the collections to be edited and/or reposted.
True, Editing enabled (default)
False, Editing DisabledEnabled = True | False
Determines if the debug panel will be displayed if Display is called or when the class is destroyed.
True, Display enabled (default)
False, Display DisabledAllVars = True | False
Sets the display of collection variables.
True, Variables that have no value are shown
False, Only variables that have values <> blank are shown (default)Show = "0,0,0,0,0,0,0,0,0,0,0"
Where each digit in the string represents a debug information pane in order (11 of them).
Setting a 1 in the string causes the corresponding pane to be open.
Setting a 0 in the string causes the corresponding pane to be closed.
Default is "0,0,1,1,0,0,0,0,0,0,0"
If you improve this code, please send me a copy! Thanks!
Hunter Beanland
hunter @ beanland.net.au
http://www.beanland.net.au/programming/
Version History
1.0 First version.
1.1 Added more Session properties & Access DB sample.
1.2 Integrated my code to "Mike's"
version of
Microsoft's code. Added Database, Application, StaticObjects, session
properties, Null and Array awareness and Mozilla support. Dictionary support
removed (my dictionaries get too big to display).
2.0 Added Editing of collections, repost and hide whole table. Cleaned up &
optimised the code.
2.1 Removed Display method (displays on
termination), fixed compatibility with file uploaders (Request.Form before a
binary read), fixed Database section header not bold if no data.
2.2 Re-added the Display method and Enabled property to allow greater
flexibility.
2.3 Changed page display time to include milliseconds
2.4 Added Javascript Debug, basic DOM Browser and bandwidth test (thanks to
Martin Krolik's ideas)
2.5 Added sorting to Javascript DOM Browser. Removed bandwidth test (too
bulky, little value)