Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions ModuleConfig.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,28 @@ component {
// Register the interceptor, it has to be here due to loading of configuration files.
controller
.getInterceptorService()
.registerInterceptor(
.registerInterceptor(
interceptorClass = "#moduleMapping#.interceptors.Debugger",
interceptorName = "debugger@cbdebugger"
);

if ( settings.debugger.showQBPanel && controller.getModuleService().isModuleRegistered( "qb" ) ) {
controller
.getInterceptorService()
.registerInterceptor(
interceptorClass = "#moduleMapping#.interceptors.QBCollector",
interceptorName = "QBCollector@cbdebugger"
);
}

if ( settings.debugger.showQBPanel && controller.getModuleService().isModuleRegistered( "quick" ) ) {
controller
.getInterceptorService()
.registerInterceptor(
interceptorClass = "#moduleMapping#.interceptors.QuickCollector",
interceptorName = "QuickCollector@cbdebugger"
);
}
}

/**
Expand All @@ -76,12 +94,12 @@ component {
function onUnload(){
// unregister interceptor
controller.getInterceptorService().unregister( interceptorName="debugger@cbdebugger" );

// Remove application helper
var appHelperArray = controller.getSetting( "ApplicationHelper" );
var mixinToRemove = "#moduleMapping#/models/Mixins.cfm";
var mixinIndex = arrayFindNoCase( appHelperArray, mixinToRemove );

// If the mixin is in the array
if( mixinIndex ) {
// Remove it
Expand Down Expand Up @@ -117,14 +135,16 @@ component {
expandedRCPanel = false,
showModulesPanel = true,
expandedModulesPanel = false,
showQBPanel = true,
expandedQBPanel = false,
showRCSnapshots = false,
wireboxCreationProfiler=false
};

// incorporate settings
structAppend( configStruct.debugger, debuggerDSL, true );
}

// This appender is part of a module, so we need to register it after the modules have been loaded.
function afterConfigurationLoad() {
var logBox = controller.getLogBox();
Expand All @@ -139,6 +159,6 @@ component {
root.addAppender( appenders[ 'tracer' ] );
root.setLevelMax( 4 );
root.setLevelMin( 0 );

}
}
39 changes: 39 additions & 0 deletions includes/css/cbox-debugger.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
cursor: pointer;
color: black;
}
.fw_subtitles{
font-size: 10px;
font-weight: bold;
color: black;
border:1px solid #D3D3D3;
background: #D7EBF9;
padding:5px 5px 5px 5px;
margin-bottom: 2px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-khtml-border-radius: 5px;
}
.fw_profilers{
font-size: 10px;
font-weight:bold;
Expand Down Expand Up @@ -209,3 +221,30 @@
background-color: #FFF6CC;
border: 1px solid #999999;
}
.fw_badge_light{
display: inline-block;
padding: .25em .4em;
font-weight: 700;
line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: .25rem;
color: black;
background: #D7EBF9;
border:1px solid #D3D3D3;
}

.fw_badge_dark{
display: inline-block;
padding: .25em .4em;
font-weight: 700;
line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: .25rem;
color: white;
border: 1px solid #2694E8;
background: #3BAAE3;
}
2 changes: 1 addition & 1 deletion includes/css/cbox-debugger.pack.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion includes/debug.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,15 @@ Description :
</div>
</cfif>

<!--- **************************************************************--->
<!--- qb debug --->
<!--- **************************************************************--->
<cfif instance.debuggerConfig.showQBPanel>
<cfinclude template="panels/qbPanel.cfm">
</cfif>

<div class="fw_renderTime">Approximate Debug Rendering Time: #GetTickCount()-DebugStartTime# ms</div>

</div>
</cfoutput>
<cfsetting enablecfoutputonly=false>
<cfsetting enablecfoutputonly=false>
12 changes: 11 additions & 1 deletion includes/js/cbox-debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,14 @@ function fw_toggleDiv(targetDiv, displayStyle){
else{
target.style.display = displayStyle;
}
}
}

function fw_showGroupedQueries() {
fw_toggleDiv("timelineQueries", "none");
fw_toggleDiv("groupedQueries", "block");
}

function fw_showTimelineQueries() {
fw_toggleDiv("groupedQueries", "none");
fw_toggleDiv("timelineQueries", "block");
}
2 changes: 1 addition & 1 deletion includes/js/cbox-debugger.pack.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

146 changes: 146 additions & 0 deletions includes/panels/qbPanel.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<cfsetting enablecfoutputonly="true">
<!-----------------------------------------------------------------------
********************************************************************************
Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
www.coldbox.org | www.luismajano.com | www.ortussolutions.com
********************************************************************************

Template : debug.cfm
Author : Luis Majano
Date : September 25, 2005
Description :
Debugging template for the application
----------------------------------------------------------------------->
<cfscript>
var isQuickInstalled = getController().getModuleService().isModuleRegistered( "quick" );
var isQBInstalled = getController().getModuleService().isModuleRegistered( "qb" );
var totalQueries = request.cbdebugger.keyExists( "qbQueries" ) ? request.cbdebugger.qbQueries.all.len() : 0;
var totalExecutionTime = !request.cbdebugger.keyExists( "qbQueries" ) ? 0 : request.cbdebugger.qbQueries.all.reduce( function( total, q ) {
return total + q.executionTime;
}, 0 );
var totalEntities = request.cbdebugger.keyExists( "quick" ) ? request.cbdebugger.quick.total : 0;
</cfscript>
<cfoutput>
<div class="fw_titles" onClick="fw_toggle('fw_qbPanel')" >
&nbsp;<cfif isQuickInstalled>Quick &##47; </cfif>qb
</div>
<div class="fw_debugContent<cfif instance.debuggerConfig.expandedQBPanel>View</cfif>" id="fw_qbPanel">
<div id="qbQueries">
<cfif NOT isQBInstalled>
qb is not installed or registered.
<cfelse>
<div class="fw_subtitles">&nbsp;Queries <span class="fw_badge_dark" style="margin-left: 1em;">#totalQueries#</span></div>
<div style="padding: 1em;">
<input type="button" style="font-size:10px" value="Grouped View" onClick="fw_showGroupedQueries()">
<input type="button" style="font-size:10px" value="Timeline View" onClick="fw_showTimelineQueries()">
</div>
<cfif totalQueries EQ 0>
No queries executed
<cfelse>
<div id="groupedQueries">
<table border="0" align="center" cellpadding="0" cellspacing="1" class="fw_debugTables">
<thead>
<tr>
<th width="5%">Count</th>
<th>Query</th>
</tr>
</thead>
<tbody>
<cfloop array="#request.cbdebugger.qbQueries.grouped.keyArray()#" index="sql">
<tr>
<td align="center">#request.cbdebugger.qbQueries.grouped[ sql ].len()#</td>
<td>#sql#</td>
</tr>
<tr style="margin-right: 2em;">
<td></td>
<td style="width: 100%;">
<table border="0" align="center" cellpadding="0" cellspacing="1" class="fw_debugTables">
<thead>
<tr>
<th width="15%">Timestamp</th>
<th width="15%">Execution Time</th>
<th>Bindings</th>
</tr>
</thead>
<tbody>
<cfloop array="#request.cbdebugger.qbQueries.grouped[ sql ]#" index="q">
<tr>
<td>#TimeFormat(q.timestamp,"hh:MM:SS.l tt")#</td>
<td>#q.executionTime# ms</td>
<td>
<cfif NOT q.bindings.isEmpty()>
<cfdump var="#q.bindings#" expand="false" />
</cfif>
</td>
</tr>
</cfloop>
</tbody>
</table>
</td>
</tr>
</cfloop>
</tbody>
</table>
</div>
<div id="timelineQueries" style="display: none;">
<table border="0" align="center" cellpadding="0" cellspacing="1" class="fw_debugTables">
<thead>
<tr>
<th>Timestamp</th>
<th width="80%">Query</th>
<th align="center">Execution Time</th>
<th>Bindings</th>
</tr>
</thead>
<tbody>
<cfloop array="#request.cbdebugger.qbQueries.all#" index="q">
<tr>
<td>#TimeFormat(q.timestamp,"hh:MM:SS.l tt")#</td>
<td>#q.sql#</td>
<td>#q.executionTime# ms</td>
<td><cfdump var="#q.bindings#" expand="false" /></td>
</tr>
</cfloop>
</tbody>
</table>
</div>
<div style="margin-top: 0.5em; margin-left: 1em;">
<div class="fw_debugTitleCell">
Total Execution Time:
</div>
<div class="fw_debugContentCell">
#totalExecutionTime# ms
</div>
</div>
</cfif>
</cfif>
</div>
<cfif isQuickInstalled>
<hr />
<div id="quickEntities" style="margin-top: 1em;">
<div class="fw_subtitles">&nbsp;Entities <span class="fw_badge_dark" style="margin-left: 1em;">#totalEntities#</span></div>
<cfif totalEntities EQ 0>
No Quick entities loaded.
<cfelse>
<table border="0" align="center" cellpadding="0" cellspacing="1" class="fw_debugTables" style="margin-top: 1em;">
<thead>
<tr>
<th width="5%">Count</th>
<th>Mapping</th>
</tr>
</thead>
<tbody>
<cfloop collection="#request.cbdebugger.quick.byMapping#" item="mapping">
<tr>
<td align="center">#request.cbdebugger.quick.byMapping[ mapping ]#</td>
<td>#mapping#</td>
</tr>
</cfloop>
</tbody>
</table>
</cfif>
</div>
</cfif>
</div>
</cfoutput>
<cfsetting enablecfoutputonly="false">
20 changes: 20 additions & 0 deletions interceptors/QBCollector.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* QB Collector Interecptor
*/
component extends="coldbox.system.Interceptor"{

// Before we capture.
function postQBExecute( event, interceptData, rc, prc ) {
param request.cbdebugger = {};
param request.cbdebugger.qbQueries = {};
param request.cbdebugger.qbQueries.grouped = {};
param request.cbdebugger.qbQueries.all = [];
arguments.interceptData.timestamp = now();
if ( !structKeyExists( request.cbdebugger.qbQueries.grouped, arguments.interceptData.sql ) ) {
request.cbdebugger.qbQueries.grouped[ arguments.interceptData.sql ] = [];
}
request.cbdebugger.qbQueries.grouped[ arguments.interceptData.sql ].append( arguments.interceptData );
request.cbdebugger.qbQueries.all.append( arguments.interceptData );
}

}
Loading