fileName = $fileName; $this->logging =( in_array('logging', $options)) ? true : false; $this->hot =( in_array('hotlogging', $options)) ? true : false; $this->fileContents =( in_array('files', $options)) ? true : false; $this->profile =( in_array('profile', $options)) ? true : false; if( $this->profile ) { JLoader::import('helpers.profiler', JPATH_COMPONENT); $this->profiler =& easyProfiler::getInstance( 'EasyLogger' ); } $this->logPath = JPATH_COMPONENT.DS.'builds'.DS.'logs'; }//function public function log($string, $error='') { if( ! $this->logging ) { return; } $ret = ''; if( $this->profile ) { $ret .= $this->profiler->mark('log'); } $ret .=( $error ) ? '
'.$error.'
' : ''; $ret .= $string; $this->log[] = $ret; if( $this->hot ) { $this->writeLog(); } }//function /** * Logs file write attempts * * @param string $from path * @param string $to path * @param string $fileContents * @param string $error */ public function logFileWrite($from='', $to='', $fileContents='', $error='') { if( ! $this->logging ) { return; } if( $from ) { $from = str_replace(JPATH_ROOT, '', $from); $fromFile = JFile::getName($from); $from = str_replace($fromFile, '', $from); } if( $to ) { $to = str_replace(JPATH_ROOT, '', $to); $toFile = JFile::getName($to); $to = str_replace($toFile, '', $to); } $ret = ''; $ret .=( $this->profile ) ? $this->profiler->mark('fileWrite') : ''; $ret .= 'Writing file
'; $ret .=( $error ) ? '
'.$error.'
' : ''; $ret .=( $from ) ? 'From: '.$from.BR.''.$fromFile.''.BR : ''; $ret .=( $to ) ? 'To: '.$to.BR.''.$toFile.''.BR : ''; if( $fileContents ) { $ret .= '
'.JText::_('File Contents').'
'; $ret .= ''; } $ret .= '
'; $this->cntCodeBoxes ++; $this->log[] = $ret; if( $this->hot ) { $this->writeLog(); } }//function public function logQuery( $query, $error=false) { if( ! $this->logging ) { return; } $ret = ''; if( $this->profile ) { $ret = $this->profiler->mark('execute Query'); } $ret .= 'Executing query'; if( $error ) { $ret .= '

'.JText::_('Error').'

'; } $ret .= '
'.JText::_('Query').'
'; $ret .= ''; $this->cntCodeBoxes ++; if( $error ) { $ret .= '
'.JText::_('Error').'
'; $ret .= ''; $this->cntCodeBoxes ++; } $ret .= '
'; $this->log[] = $ret; if( $this->hot ) { $this->writeLog(); } }//function public function writeLog() { if( ! $this->logging ) { return; } if( ! count($this->log) ) { //--No log entries return; } $path = JPATH_COMPONENT.DS.'builds'.DS.'logs'; if( ! JFile::write($this->logPath.DS.$this->fileName, implode("\n", $this->log)) ) { JError::raiseWarning(100, JText::sprintf('The file %s could no be written to path %s', $this->fileName, $this->logPath)); return false; } return true; }//function public function printLog() { if( ! $this->logging || ! count( $this->log )) { return; } echo ''; }// function }//class