Catalyst-Plugin-Profile-DBI-Log
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/Profile/DBI/Log/Controller/ControlProfiling.pm view on Meta::CPAN
<a href="/dbi/log/index" class="back-link">← Back to all requests</a>
<h1>DBI::Log — Request Detail</h1>
<div class="summary-cards">
<div class="summary-row">
<div class="card">
<div class="card-label">Request</div>
<div class="card-value"><span class="method method-$method">$method</span> $path_maybe_link</div>
</div>
<div class="card">
<div class="card-label">Recorded</div>
<div class="card-value" style="font-size:1rem">@{[ HTML::Entities::encode_entities($datetime) ]}</div>
</div>
</div>
<div class="summary-row">
<div class="card">
<div class="card-label">Total DB Time</div>
<div class="card-value">@{[ HTML::Entities::encode_entities($stats->{total_query_time}) ]}s</div>
</div>
<div class="card">
<div class="card-label">Queries</div>
<div class="card-value">$query_count</div>
</div>
</div>
</div>
<div class="table-wrap">
<table class="query-table">
<thead>
<tr>
<th>Query</th>
<th>Took</th>
<th>Stack</th>
</tr>
</thead>
<tbody>
@{[ join("\n", @query_rows) ]}
</tbody>
</table>
</div>
</div>
<script>
\$('.query').each(function (i) {
let formatted = sqlFormatter.format(\$(this).text(), { language: 'postgresql' });
\$(this).text( formatted );
});
</script>
</body>
</html>
HTML
$c->response->body($html);
}
sub generate_stack_trace_html {
my $stack_data = shift;
my $html = <<STACKTRACETABLESTART;
<h2>Stack trace</h2>
<table class="query-table">
<thead>
<tr>
<th>File</th>
<th>Line</th>
<th>Sub</th>
</tr>
</thead>
<tbody>
STACKTRACETABLESTART
for my $frame (@{ $stack_data }) {
$html .= <<STACKROW;
<tr>
<td>@{[ HTML::Entities::encode_entities($frame->{file}) ]}</td>
<td class="stat">@{[ HTML::Entities::encode_entities($frame->{line}) ]}</td>
<td class="stack-trace">@{[ HTML::Entities::encode_entities($frame->{sub}) ]}</td>
</tr>
STACKROW
}
$html .= "</tbody></table>";
return $html;
}
1;
=head1 NAME
Catalyst::Plugin::Profile::DBI::Log::Controller::ControlProfiling
=head1 DESCRIPTION
Provides the route handlers to list profiled HTTP requests, and
inspect the DB queries they executed.
See the base L<Catalyst::Plugin::Profile::DBI::Log> documentation for
more details.
=head1 AUTHOR
David Precious (BIGPRESH) C<< <davidp@preshweb.co.uk> >>
=head1 COPYRIGHT AND LICENCE
Copyright (C) 2024 by David Precious
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
__END__
( run in 3.141 seconds using v1.01-cache-2.11-cpan-1bcd28dbaf1 )