Skip to content

Commit

Permalink
2.1.1.1 show status code / content type when available ( Lucee6 )
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Apr 15, 2021
1 parent 0eb49bb commit 84a8e4b
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Application.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
request.adminType = "web";
try {
request.singleMode = getConfigSettings().mode == "single";
if ( request.singleMode)
if (request.singleMode)
request.adminType="server";
} catch (e){
// lucee 6.0 only
Expand Down
2 changes: 1 addition & 1 deletion box.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name":"Lucee Performance Analyzer",
"author":"Zac Spitzer",
"version":"2.1.1.0",
"version":"2.1.1.1",
"bugs":"https://github.com/zspitzer/lucee-performance-analyzer/issues",
"thumbnail": "https://raw.githubusercontent.com/zspitzer/lucee-performance-analyzer/master/build/images/logo.png",
"changelog":"",
Expand Down
Binary file not shown.
14 changes: 13 additions & 1 deletion source/cfml/plugins/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ td, th {
padding: 4 4 4 4;
vertical-align:top;
}
th {/* like .tblHead */
th, .maintbl th {/* like .tblHead */
background-color:#39c; /* ABC */
color:#efede5;
font-weight:normal;
Expand Down Expand Up @@ -89,3 +89,15 @@ a {
.header {
padding-bottom:12px;
}

.statusCode-4, .statusCode-5, .statusCode-6{
background-color: red;
color: white;
}

.statusCode-1, .statusCode-2 {
/*normal */
}
.statusCode-3 {
background-color: yellow;
}
5 changes: 4 additions & 1 deletion source/cfml/plugins/footer.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
</cfscript>
<cfoutput>
<hr>
<p>This report is based on all the debugging logs currently in memory ( #this.perf.getRawLogCount()# logs, #this.perf.getDebugMemUsage()# ) click column headers to sort</p>
<p>This report is based on all the debugging logs currently in memory ( #this.perf.getRawLogCount()# logs, #this.perf.getDebugMemUsage()# )
<cfif this.perf.getRawLogCount() gt 0> click column headers to sort </cfif>

</p>

<cfif hasJavaMethod(getPageContext().getConfig().getDebuggerPool(), "purge" )>
<input type="button" class="bm button submit" name="mainAction" value="Purge Logs"
Expand Down
35 changes: 21 additions & 14 deletions source/cfml/plugins/perf.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ component {
<cfquery name="local.q_parts" dbtype="query">
select template, lines, min(_min) as minTime, max(_max) as maxTime, avg(_avg) as avgTime,
sum(total) as totalTime, sum(_count) as totalCount,
sum(total) as total, count(*) as executions, snippet
sum(total) as total, count(*) as executions, snippet, start, _end
from q_parts
group by template, lines, snippet
group by template, lines, snippet, start, _end
order by totalTime desc
</cfquery>
```
Expand Down Expand Up @@ -490,7 +490,7 @@ component {
}

public struct function getDebugLogs( required array logs ){
var q = QueryNew( "template,requestUrl,path,total,query,load,app,scope,exceptions,starttime,id,size,isThread" );
var q = QueryNew( "template,requestUrl,path,total,query,load,app,scope,exceptions,starttime,id,size,isThread,statusCode,ContentType,ContentLength" );
local.totals = {
app = 0,
query: 0,
Expand Down Expand Up @@ -539,20 +539,27 @@ component {


local.r = QueryAddRow( q );
QuerySetCell( local.q, "size", log.size, local.r);
QuerySetCell( local.q, "id", log.id, local.r);
QuerySetCell( local.q, "starttime", log.starttime, local.r);
QuerySetCell( local.q, "template", local.cgi.script_name, local.r);
QuerySetCell( local.q, "path", path, local.r);
QuerySetCell( local.q, "total", _total, local.r);
QuerySetCell( local.q, "query", _query, local.r);
QuerySetCell( local.q, "load", _load, local.r);
QuerySetCell( local.q, "app", _app, local.r);
QuerySetCell( local.q, "scope", _scope, local.r);
QuerySetCell( local.q, "exceptions", _exp, local.r);
QuerySetCell( local.q, "size", log.size, local.r );
QuerySetCell( local.q, "id", log.id, local.r );
QuerySetCell( local.q, "starttime", log.starttime, local.r );
QuerySetCell( local.q, "template", local.cgi.script_name, local.r );
QuerySetCell( local.q, "path", path, local.r );
QuerySetCell( local.q, "total", _total, local.r );
QuerySetCell( local.q, "query", _query, local.r );
QuerySetCell( local.q, "load", _load, local.r );
QuerySetCell( local.q, "app", _app, local.r );
QuerySetCell( local.q, "scope", _scope, local.r );
QuerySetCell( local.q, "exceptions", _exp, local.r );
QuerySetCell( local.q, "requestUrl", local.log.scope.cgi.REQUEST_URL, local.r );
QuerySetCell( local.q, "isThread", ( Len( local.log.scope.cgi.HTTP_USER_AGENT ) eq 0 ), local.r );

if ( StructKeyExists( log, "statusCode" ) )
QuerySetCell( local.q, "statusCode", log.statusCode, local.r );
if ( StructKeyExists( log, "ContentType" ) )
QuerySetCell( local.q, "ContentType", log.ContentType, local.r );
if ( StructKeyExists( log, "ContentLength" ) )
QuerySetCell( local.q, "ContentLength", log.ContentLength, local.r );

local.totals.size += + local.log.size / 1000;
local.totals.app += _app;
local.totals.query += _query;
Expand Down
10 changes: 6 additions & 4 deletions source/cfml/plugins/requests.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</cfif>
<tr class="#altRow( local.q.currentRow )#">
<td>#renderRequestLink( arguments.req, local.q.path, local.q.id )# <cfif local.q.isThread>(thread)</cfif></td>
<td class="statusCode-#Left(local.q.statusCode,1)#">#listFirst(local.q.statusCode," ")#</td>
<td>
<a href="#local.baseUrl#&url=#urlEncodedFormat(q.requestUrl)#" title="Filter by Request URL">By Url</a>,&nbsp;
<cfset local.host = this.Perf.getHost(q.requestUrl)>
Expand All @@ -45,7 +46,7 @@
<td align="right">#prettyTime( local.q.load )#</td>
<td align="right">#prettyNum( local.q.scope )#</td>
<td align="right">#prettyNum( local.q.exceptions )#</td>
<td align="right">#prettyNum( local.q.size / 1000 )#</td>
<td align="right" title="Kb">#prettyNum( local.q.size / 1000 )#</td>
</tr>
</cfoutput>
</cfloop>
Expand All @@ -54,15 +55,15 @@

<cfsavecontent variable="local.totals">
<tr class="log-totals">
<td colspan="3" align="center">Totals</td>
<td colspan="4" align="center">Totals</td>
<cfoutput>
<td align="right">#prettyTime( local.logs.totals.total )#</td>
<td align="right">#prettyTime( local.logs.totals.app )#</td>
<td align="right">#prettyTime( local.logs.totals.query )#</td>
<td align="right">#prettyTime( local.logs.totals.load )#</td>
<td align="right">#prettyNum( local.logs.totals.scope )#</td>
<td align="right">#prettyNum( local.logs.totals.exceptions )#</td>
<td align="right">#prettyNum( local.logs.totals.size )#</td>
<td align="right" title="Kb">#prettyNum( local.logs.totals.size )#</td>
</cfoutput>
</tr>
</cfsavecontent>
Expand All @@ -71,6 +72,7 @@
<thead>
<tr>
<th data-type="text">Url</th>
<th title="http status code">Code</th>
<th data-type="text">Filter</th>
<th>Timestamp</th>
<th>Total</th>
Expand All @@ -79,7 +81,7 @@
<th>Load</th>
<th>Scope Problems</th>
<th>Exceptions</th>
<th>Size (Kb)</th>
<th>Log Size</th>
</tr>
<cfif local.q.recordcount gt 10>
<cfoutput>#totals#</cfoutput>
Expand Down
4 changes: 4 additions & 0 deletions source/cfml/plugins/settings.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,8 @@
</tfoot>
</table>
</form>

<p>
<b>Please consider making a <a href="https://opencollective.com/Lucee">donation / supporting</a> the Lucee project</b>, so we can make Lucee even better!
</p>
</cfoutput>
39 changes: 36 additions & 3 deletions source/cfml/plugins/toolbar.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
variables.template = arguments.req.template;
variables.req = arguments.req;
local.reports = ["Requests", "Templates", "Scopes", "Queries", "Timers", "Exceptions", "Dumps", "Aborts", "Traces", "Memory", "Threads", "Settings"];
local.reports = ["Requests", "Templates", "Scopes", "Queries", "Timers", "Exceptions", "Dumps", "Aborts", "Traces", "Parts", "Memory", "Threads", "Settings"];
//if ( Len( arguments.req.template ) || Len( arguments.req.url ) || Len( arguments.req.log ) )
ArrayPrepend(local.reports, "Analysis");
local.path_reports = ["Requests", "Templates", "Scopes", "Queries", "Timers", "Exceptions", "Dumps", "Aborts", "Traces", "Parts"];
Expand Down Expand Up @@ -108,8 +108,41 @@
</h3>
<cfset local.singleLog = this.perf.getLog(arguments.req.log )>
<cfif StructCount(singleLog)>
Url: #encodeForHtml( singleLog.scope.cgi.request_url )#<br>
User-Agent: <cfif len(singleLog.scope.cgi.http_user_agent) eq 0>Empty, probably a Lucee thread<cfelse>#encodeForHtml(singleLog.scope.cgi.http_user_agent)#</cfif><br>
<table>
<tr>
<td>Url</td>
<td><a href="#singleLog.scope.cgi.request_url#" target="blank" rel="noopener">#encodeForHtml( singleLog.scope.cgi.request_url )#</a></td>
</tr>
<cfif len(singleLog.scope.cgi.http_referer)>
<tr>
<td>Http Referer</td>
<td><a href="#singleLog.scope.cgi.http_referer#" target="blank" rel="noopener">#encodeForHtml( singleLog.scope.cgi.http_referer )#</a></td>
</tr>
</cfif>
<tr>
<td>User-Agent</td>
<td><cfif len(singleLog.scope.cgi.http_user_agent) eq 0>Empty, probably a Lucee thread<cfelse>#encodeForHtml(singleLog.scope.cgi.http_user_agent)#</cfif></td>
</tr>
<cfif structKeyExists(singleLog, "StatusCode")>
<tr>
<td>Status-Code</td>
<td><span class="statusCode-#Left(singleLog.statusCode,1)#">#listFirst(singleLog.statusCode," ")#</span></td>
</tr>
</cfif>
<cfif structKeyExists(singleLog, "contentType")>
<tr>
<td>Content-Type</td>
<td>#singleLog.contentType#</td>
</tr>
</cfif>
<cfif structKeyExists(singleLog, "contentLength") and len(singleLog.contentLength) gt 0>
<tr>
<td>Content-Length</td>
<td>#singleLog.contentLength#</td>
</tr>
</cfif>

</table>
<cfelse>
Log not found?<br>
</cfif>
Expand Down

0 comments on commit 84a8e4b

Please sign in to comment.