[Catalyst] Why does $c->stats require -Debug flag?

Jon Schutz jon+catalyst at youramigo.com
Sat Apr 12 12:07:49 BST 2008


On Sat, 2008-04-12 at 10:45 +0100, Richard Jones wrote:

> > I think you probably want $c->stats->report, but can't think why you're
> > calling this directly as it is invoked in finalize() if -Debug or -Stats
> > is set.  See perldoc Catalyst::Stats.
> > 
> 
> Because I never got round to delving into Catalyst::Stats or 
> Tree::Simple inner workings. I copy/pasted the example from 
> http://www.onemogin.com/blog/559-adding-action-timings-to-your-output.html 
> into my Root::end() method and it just worked.
> 
> At least it did until I removed the -Debug flag. And then tried to 
> recover functionality by updating Catalyst::Stats to the latest version, 
> which also updated Catalyst itself (I was using an earlier 5.70x). So 
> I've no idea in which module(s) the change occurred to stop the process 
> working. Maybe someone more familiar with these modules could offer a clue?

Following the example in the blog post, the solution is to set -Stats
and change your Root::end() method to something like:

@report = $stats->report;
$c->stash->{'action_stats'} = \@report;

and then adjust your template as now you're getting an array of arrays
rather than an array of hashrefs.

Prior to 5.7012, $c->stats was an internal object (in so far as it was
not documented as part of the API) so anyone manipulating it directly
does so at their own risk.  Catalyst::Stats was introduced to define an
interface for the stats object so that one could safely override the
default implementation if they wished; the default implementation also
introduced profiling methods that were not there before.

-- 

Jon Schutz                        My tech notes http://notes.jschutz.net
Chief Technology Officer                        http://www.youramigo.com
YourAmigo         




More information about the Catalyst mailing list