├── firedebug.inc ├── json ├── JSON.asp └── JSON_UTIL.asp ├── readme.md └── test-example.asp /firedebug.inc: -------------------------------------------------------------------------------- 1 | <% 2 | '---------------------------------------------------------------------- 3 | 'By David Meagor - BooRoo.com 2012 (http://booroo.com) 4 | ' 5 | 'released under MIT license (http://www.opensource.org/licenses/mit-license.php) 6 | ' 7 | 'requires json.asp (http://code.google.com/p/aspjson/ ) 8 | '---------------------------------------------------------------------- 9 | 10 | 'Functions 11 | '----------- 12 | ' log value 13 | ' log_type type,label,value 14 | ' log_group_start label,collapsed (true/false) 15 | ' log_group_end 16 | ' log_table array (requires 2 dimensional array) 17 | '---------------------------------------------------------------------- 18 | 19 | Class FireASP 20 | 21 | 'Private variables 22 | Private headerPrefix 23 | Private headerCounter 24 | Private protocolHeaderKeys(3) 25 | Private protocolHeaderVals(3) 26 | Private pageStartTime 27 | 28 | 'Singleton Instance 29 | Private instance 30 | 31 | Private Sub Class_Initialize() 32 | pageStartTime = timer 33 | 'Set the header prefix 34 | headerPrefix = "X-Wf-" 35 | 36 | headerCounter = 0 37 | 38 | protocolHeaderKeys(0) = "Protocol-1" 39 | protocolHeaderKeys(1) = "1-Plugin-1" 40 | protocolHeaderKeys(2) = "1-Structure-1" 41 | 42 | protocolHeaderVals(0) = "http://meta.wildfirehq.org/Protocol/JsonStream/0.2" 43 | protocolHeaderVals(1) = "http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3" 44 | protocolHeaderVals(2) = "http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1" 45 | 46 | 'Turn on Page buffering 47 | Response.Buffer = True 48 | 49 | For i = 0 to 2 50 | 51 | 'Response.Write protocolHeaders(i) 52 | Response.addHeader headerPrefix & protocolHeaderKeys(i), protocolHeaderVals(i) 53 | 54 | next 55 | 56 | End Sub 57 | 58 | Private Sub Class_Terminate() 59 | firebugDump() 60 | 61 | end sub 62 | 63 | 64 | 65 | Public Function log( ByRef obj ) 66 | dim str 67 | 68 | headerCounter= headerCounter + 1 69 | 70 | str= "|[{""Type"":""LOG""},"&toJson(obj)&"]|" 71 | msgLength = len(str) - 2 72 | str=msgLength&str 73 | Response.addHeader headerPrefix & "1-1-1-" & headerCounter , str 74 | End Function 75 | 76 | Public Function log_type( logtype,label,ByRef obj ) 77 | dim str 78 | 79 | headerCounter= headerCounter + 1 80 | 81 | str= "|[{""Type"":"""&logtype&""",""Label"":"""&label&"""},"&toJson(obj)&"]|" 82 | msgLength = len(str) - 2 83 | str=msgLength&str 84 | Response.addHeader headerPrefix & "1-1-1-" & headerCounter , str 85 | End Function 86 | 87 | Public Function log_group_start( label,Collapsed ) 88 | dim str 89 | 90 | if Collapsed=true then Collapsed="true" else Collapsed="false" 91 | 92 | headerCounter= headerCounter + 1 93 | 94 | str= "|[{""Type"":""GROUP_START"",""Label"":"""&label&""",""Collapsed"":"""&Collapsed&"""},"&toJson(obj)&"]|" 95 | msgLength = len(str) - 2 96 | str=msgLength&str 97 | Response.addHeader headerPrefix & "1-1-1-" & headerCounter , str 98 | End Function 99 | 100 | Public Function log_group_end() 101 | dim str 102 | 103 | headerCounter= headerCounter + 1 104 | 105 | str= "|[{""Type"":""GROUP_END""}]|" 106 | msgLength = len(str) - 2 107 | str=msgLength&str 108 | Response.addHeader headerPrefix & "1-1-1-" & headerCounter , str 109 | End Function 110 | 111 | 112 | Public function firebugDump() 113 | 114 | dim str,lasterr 115 | 116 | 117 | 118 | 119 | set objErr=Server.GetLastError() 120 | if objErr.Number<>0 then 121 | 122 | log_type "ERROR","","objErr.Number: "&objErr.Number 123 | log_type "ERROR","","err.Number: "&err.Number 124 | log_type "ERROR","","ERROR ON PAGE: "&objErr.file 125 | log_type "ERROR","",err.Source 126 | log_type "ERROR","","Error: "&objErr.Description &" on line: "&objErr.line 127 | if objErr.column>1 then log_type "ERROR","","Column: "&objErr.column 128 | if objErr.ASPDescription<>"" then log_type "ERROR","","Description: "&objErr.ASPDescription 129 | else 130 | log_type "INFO","SUCCESS","(Time taken: "&formatnumber((timer-pageStartTime)*1000,2)&"ms)" 131 | 132 | 133 | end if 134 | 135 | 136 | log_group_start "ASP System Collections",true 137 | 138 | 139 | 'SESSION 140 | Set member = jsObject() 141 | for each str in session.contents 142 | member(str) = Session.Contents(str) 143 | next 144 | log_type "INFO","SESSION",member 145 | 146 | 'POST 147 | Set member = jsObject() 148 | for each str in request.form 149 | member(str) = request.form(str) 150 | next 151 | log_type "INFO","POST",member 152 | 153 | 154 | 'GET 155 | Set member = jsObject() 156 | for each str in request.querystring 157 | member(str) = request.querystring(str) 158 | next 159 | log_type "INFO","GET",member 160 | 161 | 'Application 162 | Set member = jsObject() 163 | for each str in Application.Contents 164 | 'response.write(vartype(application(str))&",") 165 | if vartype(application(str))<>8204 then 166 | member(str) = application.contents(str) 167 | else 168 | member(str) = "Not shown" 169 | end if 170 | next 171 | log_type "INFO","APPLICATION",member 172 | 173 | 'SERVER 174 | Set member = jsObject() 175 | for each str in Request.ServerVariables 176 | member(str) = request.ServerVariables(str) 177 | next 178 | log_type "INFO","SERVER",member 179 | 180 | log_group_end() 181 | 182 | 183 | end function 184 | 185 | 186 | 187 | 'Get singleton instance 188 | Public Function getInstance 189 | 190 | If IsNull( instance ) then 191 | set instance = new FireASP 192 | End if 193 | 194 | getInstance = instance 195 | 196 | End Function 197 | 198 | End Class 199 | Set FIRE_ASP = new FireASP 200 | 201 | sub log( ByRef msg ) 202 | call FIRE_ASP.log(msg) 203 | end sub 204 | 205 | 206 | sub log_type( logtype,label,ByRef obj ) 207 | call FIRE_ASP.log_type(logtype,label,obj) 208 | end sub 209 | 210 | 211 | sub log_group_start( label,collapsed ) 212 | call FIRE_ASP.log_group_start(label,collapsed) 213 | end sub 214 | 215 | sub log_group_end() 216 | call FIRE_ASP.log_group_end() 217 | end sub 218 | 219 | sub log_table(ByRef obj) 220 | call FIRE_ASP.log_type("TABLE","Array",obj) 221 | end sub 222 | 223 | 224 | 225 | %> 226 | -------------------------------------------------------------------------------- /json/JSON.asp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmeagor/ClassicASP-FirePHP/1f136ab125b33ef26e367492d8b0c9631c743e78/json/JSON.asp -------------------------------------------------------------------------------- /json/JSON_UTIL.asp: -------------------------------------------------------------------------------- 1 | <% 2 | Function QueryToJSON(dbc, sql) 3 | Dim rs, jsa 4 | Set rs = dbc.Execute(sql) 5 | Set jsa = jsArray() 6 | While Not (rs.EOF Or rs.BOF) 7 | Set jsa(Null) = jsObject() 8 | For Each col In rs.Fields 9 | jsa(Null)(col.Name) = col.Value 10 | Next 11 | rs.MoveNext 12 | Wend 13 | Set QueryToJSON = jsa 14 | End Function 15 | %> -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Classic ASP debugging made slightly less painful 2 | 3 | Debugging legacy Classic ASP scripts is a painful job. This script will enable 4 | you to use FirePHP (https://github.com/firephp/firephp-for-firefox-devtools) to 5 | log errors and messages to the Firefox console window. 6 | 7 | It's particularly useful for catching errors and problems with AJAX/JSON requests 8 | where outputting to the browser will break the JSON format. 9 | 10 | released under MIT license (http://www.opensource.org/licenses/mit-license.php) 11 | 12 | requires json.asp (http://code.google.com/p/aspjson/ ) 13 | 14 | inspired by FireASP by Jonathan Dalrymple's Fire ASP script 15 | 16 | 17 | ## Installation 18 | 19 | 1. Install FirePHP for FireFox (https://github.com/firephp/firephp-for-firefox-devtools) 20 | 2. You may have to first go to about:config and set xpinstall.signatures.required to false 21 | 3. Ensure both fireasp and json.asp are included in every page you wish to debug 22 | 23 | ## How it works 24 | 25 | When you call the various log methods the script will attach additional headers to the 26 | response which will be interperated by the FirePHP extension and then displayed in 27 | the firefox console. 28 | 29 | If you are using ajax/json calls then you can log debugging into without breaking your 30 | front end. 31 | 32 | ## Use with sql queries 33 | 34 | There is no built in support for SQL however we recommend you create some helper functions to store details of your ASP SQL queries into an array along with query times and success/fail status as they are called. Then add some code into the class termination function to log out these results into an SQL log group. 35 | 36 | ## Group log entries functions 37 | 38 | log "hellow world" to output to the console 39 | 40 | log_group_start( label, collapsed ) 41 | log "Some grouped text" 42 | log "Bla bla bla" 43 | log "and so on..." 44 | log_group_end() 45 | 46 | log_type( logtype,label, obj ) 47 | ' logtype : "INFO", "ERROR", "LOG" or "WARN" for different colours/icons. 48 | ' label : add label to the variable/object you are about to output on the same line. 49 | ' obj : array, string, json object 50 | 51 | 52 | ## Disclaimer 53 | This source was developed over a decade ago by BooRoo Limited, now known as [Shout.com](https://Shout.com). We have long since migrated away to the C# .NET platform so this script is not maintained. 54 | -------------------------------------------------------------------------------- /test-example.asp: -------------------------------------------------------------------------------- 1 | <%@ LANGUAGE=VBScript CODEPAGE="65001"%> 2 | 3 | 4 | <% 5 | '---------------------------------------------------------------------- 6 | 'By David Meagor - BooRoo.com 2012 (http://booroo.com) 7 | ' 8 | 'released under MIT license (http://www.opensource.org/licenses/mit-license.php) 9 | ' 10 | 'requires json.asp (http://code.google.com/p/aspjson/ ) 11 | '---------------------------------------------------------------------- 12 | 13 | 'Functions 14 | '----------- 15 | ' log value 16 | ' log_type type,label,value 17 | ' log_group_start label,collapsed (true/false) 18 | ' log_group_end 19 | ' log_table array (requires 2 dimensional array) 20 | '---------------------------------------------------------------------- 21 | 22 | 23 | response.write("check firebug console output for debugging info") 24 | 25 | 'string 26 | log("Testing") 27 | 28 | 29 | 'array 30 | dim hello(5,1) 31 | 32 | hello(0,0)="Oranges" 33 | hello(0,1)=1234 34 | hello(0,0)="Oranges" 35 | hello(1,0)="Apples" 36 | hello(1,1)=852 37 | hello(2,0)="Pears" 38 | hello(2,1)=645 39 | 40 | log hello 41 | 42 | 'log 2 dimensional array as a table 43 | log_table hello 44 | 45 | 46 | 'groups and icon types 47 | log_group_start "My Group",false 48 | log_type "WARN","Some label","Message" 49 | log_type "ERROR","Some label","Message" 50 | log_type "INFO","Some label","Message" 51 | log_group_end 52 | 53 | 'more complex json object 54 | Dim member 55 | 56 | Set details = jsObject() 57 | details("Something") = "rah rah" 58 | 59 | Set member = jsObject() 60 | member("name") = "Jim" 61 | member("surname") = "Smith" 62 | member("message") = "Hello World" 63 | set member("details") = details 64 | log member 65 | 66 | 67 | 68 | 'uncomment to trigger error report 69 | 'a="b"*"c" 70 | 71 | 72 | %> 73 | --------------------------------------------------------------------------------