Title: CF Pest Control
1CF Pest Control
- By Shlomy Gantz
- President, BlueBrick Inc.
- Presented by
- Sandra Clark
- slclark_at_shayna.com
2Famous Last words
- if debugging is defined as the art of taking
bugs out of a program , programming must be
putting them in - ..Its not a bug, Its a feature
-
Microsoft
3Types of bugs
- Syntax Error
- Run-Time Errors
- Logical Errors
4Types of bugs - Syntax Errors
ltCFSET ClientName Shlomy Gantzgt
ltCFSET URLstr URLstr urlendcodedformat(ClientN
ame)gt
5Types of bugs - Run-Time Errors
ltCFQUERY NAMEGetOverPaidEmp DatasourcePayroll
gt SELECT SUM(Salary) AS TotalSalary, COUNT(Emp_ID
) as NumOfEmployees FROM AnnualSalary WHERE
SALARY gt 100000 lt/CFQUERYgt ltCFSET AVGSalary
GetOverPaidEmp.TotalSalary/GetOverPaidEmp.NumOfEmp
loyeesgt ltCFOUTPUTgtAVGSalarylt/CFOUTPUTgt
6Types of bugs - Logical Errors
ltCFSET MyListShlomy,Michael,Emily,Abrahamgt
ltCFSET ShlomyExists_YN listfind(MyList,shlo
my)gt ltCFOUTPUTgtYesNoFormat(ShlomyExists_YN)
lt/CFOUTPUTgt
7Other things that can go wrong
- Database connection (ODBC,MDAC )
- Cold Fusion server
- Web Server
- OS
- Hardware
8Debugging Steps
- Plan
- Back-up
- Isolate
- Find The error
- Fix - Dont patch
- Look for similar
- Document
9Debuggers Block
- If all else fails
- and if that doesnt work
10Cold Fusion Administrator
11Cold Fusion Administrator
12Enable CFML stack trace
- CF tracks what tags have run during page process.
- Can be used either through CFTRY/CFCATCH or the
HomeSite - Debugger
13Report Execution Times
14Show Variables
- Show all variables processed by ColdFusion
- Application
- Cookie
- Server
- CGI
- Form
- Session
- Client
- Request
- URL
15Detail View
- Breakdown of all templates run during a page
process. - Processing time for each template
16Database Activity
- Query Name
- RecordCount
- Processing Time
- Query Executed
17Enable Performance Monitoring
18Enable Robust Exception Information
- physical path of template
- URI of template
- line number and line snippet
- SQL statement used (if any)
- Data source name (if any)
- Java stack trace
19Debugging IP Addresses
- By Default All when debugging is turned on all
users can see debug information. - You can restrict access to the debugging info
through this feature by IP address
20Log Files
- Easier Log File Administration
21Log Files
22System Probes
- Monitor your ColdFusion Applications
23Code Analyzer
24Debugging with HomeSite
- Setting up Development Mapping.
25Using the interactive debugger
26Debugging CF applications
- Show your variables (not only once)
- Create breakpoints and Follow the flow
- Use Exception handling to automatically alert
when errors occur - Look at your application logs
- ltCFDUMPgt
27ltCFABORTgt ltCFOUTPUTgt
- Using CFABORT to create breakpoints
- ltcfinclude template"Header.cfm"gt
- ltcfquery datasource"dsn"
name"getContacts"gt - Select from Contacts
- WHERE Active_YN1
- lt/cfquerygt
- ltcfoutputgtgetContacts.recordcountlt/cfoutputgt
- ltcfabortgt
28ltCFABORTgt ltCFOUTPUTgt
-
- ltCFIF gt
- Step 1
- ltCFIF ..gt
- Step 1.1
- ltCFELSEgt
- Step 1.2
- lt/CFIFgt
- ltCFELSEgt
- Step 2
- lt/CFIFgt
29Debugging in CFML
- ltcfquery debuggt
- ltcfstoredproc debugyesnogt
- ltcfsetting showdebugoutputyes/nogt
30Debugging CF applications
- ltCFERRORgt
- ltCFTHROWgt
- ltCFRETHROWgt
- ltCFCATCHgtltCFTRYgt
- ltCFLOGgt
- ltCFTRACEgt
31ltCFERRORgt
- ltCFERROR TYPE"Request" or "Validation" or
"Monitor" or "Exception" TEMPLATE"template_path"
MAILTO"email_address" EXCEPTION"exception_type"gt
32ltCFTRYgtltCFCATCHgt
- ltCFTRYgt
- ... Add code here
- ltCFCATCH TYPE"exceptiontype"gt
- ... Add exception processing code here lt/CFCATCHgt
- ... Additional CFCATCH blocks go here lt/CFTRYgt
33ltCFTHROWgtltCFRETHROWgt
- ltCFTHROW TYPE"exception_type" MESSAGE"message"
DETAIL"detail_description" ERRORCODE"error_code"
EXTENDEDINFO"additional_information"gt
34ltCFLOGgt
- ltcflog type"Error" file"myapp_errors"
text"Exception error -- Exception type
error.type Template error.template, Remote
Address error.remoteAddress, HTTP Rerference
error.HTTPReferer Diagnositcs
error.diagnostics"gt
35ltCFTRACEgt
- ltcftrace abort "Yes or No"
- category "string"
- inline "Yes or No"
- text "string"
- type "format"
- var "variable_name" gt
36IsDebugMode()
- ltcfif IsDebugMode()gt
- lth3gtDebugging is set in the ColdFusion
Administratorlt/h3gt - ltcfelsegt
- lth3gtDebugging is disabledlt/h3gt
- lt/cfifgt
37Application Logs
- Read your application logs regularly
- Error","TID199","07/27/00","133235","127.0.0.1"
,"Mozilla/4.0 (compatible MSIE 4.01 Windows
NT)","An error has occurred. HTTP/1.0 404 Object
Not Found - "Error","TID199","07/27/00","133245","127.0.0.1
","Mozilla/4.0 (compatible MSIE 4.01 Windows
NT)","Error resolving parameter SLOT_IDColdFusion
was unable to determine the value of the
parameter. This problem is very likely due to the
fact that either You have misspelled the
parameter name, or You have not specified a
QUERY - attribute for a CFOUTPUT, CFMAIL, or CFTABLE
tag.The error occurred while evaluating the
expression slot_id The error occurred while
processing an element with a general identifier
of (slot_id), occupying document position
(412) to (420) in the template file
D\wwwroot\cfun2000\Examples\JS\JSexample1_CFMW\ed
it_def.cfmThespecific sequence of files included
or processed sD\WWWROOT\CFUN2000\EXAMPLES\JS\JSE
XAMPLE1_CFMW\EDIT_DEF.CFM nbspnbspnbspnbsp
- .Date/Time 07/27/00 133245Browser Mozilla/4.0
(compatible MSIE 4.01 Windows NT)Remote
Address 127.0.0.1HTTP Referer
http//127.0.0.1/cfun2000/Examples/JS/JSexample1_C
FMW/EDIT.HTMLTemplate D\wwwroot\cfun2000\Example
s\JS\JSexample1_CFMW\edit_def.cfm - "Warning","TID152","07/27/00","150721","In a
CF_TagName construct custom tag file
'C\CFUSION\CustomTags\Pages.cfm' will occlude
custom tag file 'C\CFUSION\CustomTags\cf_pages\Pa
ges.cfm'." -
- "Warning","TID152","07/27/00","150721","In a
CF_TagName construct custom tag file
'C\CFUSION\CustomTags\Pages.cfm' will occlude
custom tag file - 'C\CFUSION\CustomTags\cf_pages\images\Pa
ges.cfm'."
38CFDUMP
- Read your application logs regularly
39Debugging Databases
40Common Mistakes
- So what are we doing wrong?
41Tools Techniques
- ltCFMAILgt Alerts
- Monitoring Tools (http//www.pingalink.com )
- Testing Tools (http//www.opendemand.com )
- BugTraq
- Automatic Code Generation Tools
- CodeSaver / CodeCharge / CommerceBlocks
- LoRCAT
42QA