Right now just want to setup a very simple logger, which tells me the time taken for the page to render and how much memory was used.
I setup a super ultra light module as follows:
public function init() {
$this->addHookBefore('Page::render', $this, 'timeStart');
$this->addHookAfter('Page::render', $this, 'getStat');
}
public function timeStart(){
$this->$timestart = microtime(true);
}
public function timeNow(){
return microtime(true)-$this->$timestart;
}
public function convert($size) {
$unit=array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
}
public function getMemory(){
return $this->convert(memory_get_peak_usage(true));
}
public function getStat(){
echo '<!-- Page generated in '.$this->timeNow().' secs, Memory Usage: '.$this->getMemory().' -->';
}
issue is: i want to hook into the very first and very last instance of processwire..i cant really seem to find the right hooks, or a documentation about it?
cheers