/** * Private constructor */ private function __construct() { $this->restINI = eZINI::instance('rest.ini'); $this->eZDebug = eZDebug::instance(); $this->debug = ezcDebug::getInstance(); $this->debug->setOutputFormatter(new ezpRestDebugPHPFormatter()); }
/** * Test scenario for issue #13956: eZDebug::accumulatorStop( $key, true ) does not remove the recursive counter * * @link http://issues.ez.no/13956 * @group issue_13956 */ function testAccumulatorStartMultipleResursiveCounter() { self::markTestSkipped("Pending bugfix"); eZDebug::accumulatorStart(__METHOD__, false, false, true); eZDebug::accumulatorStart(__METHOD__, false, false, true); eZDebug::accumulatorStop(__METHOD__, true); eZDebug::accumulatorStop(__METHOD__, true); eZDebug::accumulatorStart(__METHOD__, false, false, true); $debug = eZDebug::instance(); $this->assertEquals(0, $debug->TimeAccumulatorList[__METHOD__]['recursive_counter']); }
/** * Returns true if the condition $conditionName is considered enabled. * * @param string $conditionName Name of the condition * * @return bool */ static function isConditionTrue( $conditionName, $messageType ) { $ini = eZINI::instance( 'debug.ini' ); if ( $ini->variable( 'DebugSettings', 'ConditionDebug' ) != 'enabled' ) return false; $generalSetting = 'GeneralCondition'; if ( $ini->hasVariable( $generalSetting, $conditionName ) ) return $ini->variable( $generalSetting, $conditionName ) == 'enabled'; $specificSetting = eZDebug::instance()->messageName( $messageType ) . 'Condition'; if ( $ini->hasVariable( $specificSetting, $conditionName ) ) return $ini->variable( $specificSetting, $conditionName ) == 'enabled'; }
public static function doLog($logmethod, array $data, &$output) { global $scriptStartTime; // Inject all the measured KPIs as "timers" into pinba, saving actual data in the "data" member self::$timers = array(); foreach ($data as $varname => $value) { self::$timers[] = array("value" => 0, "tags" => array($varname), "started" => false, "data" => $value); } // save other data as well self::$doc_size = strlen($output); // the start time from ezdebug is most likely lower than the one from pinba lib if ($scriptStartTime == 0) { $debug = eZDebug::instance(); $scriptStartTime = $debug->ScriptStart; } self::$start = $scriptStartTime; // last but not least, flush data to the server static::flush(); }
/** * Return ... and stores the warnings generated while parsing the file. * * @todo parse for validity * @todo we are not checking if a php closing tag is followed by whitespace only lines */ protected static function parseTplFile($filename, &$warnings) { $debug = eZDebug::instance(); $messagecount = count($debug->DebugStrings); $ok = self::$tpl->validateTemplateFile($filename); if (!$ok) { if (count($debug->DebugStrings) > $messagecount) { foreach (array_slice($debug->DebugStrings, $messagecount) as $msg) { $line = null; if (preg_match('#@ ' . str_replace('.', '\\.', $filename) . '\\:([0-9]+)#', $msg['String'], $matches)) { $line = $matches[1]; } $warnings[] = array(preg_replace('#parser error @ ' . str_replace('.', '\\.', $filename) . '(\\\\|\\:[0-9]+)\\[[0-9]+\\]#', '', $msg['String']), $filename, $line, ''); } } else { $warnings[] = array('Template file invalid', $filename, null, ''); } } return true; }
static function isConditionTrue($conditionName, $messageType) { global $eZDebugSettingINIObject; $ini = $eZDebugSettingINIObject; if (isset($eZDebugSettingINIObject) and $ini instanceof eZINI) { if ($ini->variable('DebugSettings', 'ConditionDebug') != 'enabled') { return false; } $generalSetting = 'GeneralCondition'; $debug = eZDebug::instance(); $debugName = $debug->messageName($messageType); $specificSetting = $debugName . 'Condition'; if ($ini->hasVariable($generalSetting, $conditionName)) { return $ini->variable($generalSetting, $conditionName) == 'enabled'; } if ($ini->hasVariable($specificSetting, $conditionName)) { return $ini->variable($specificSetting, $conditionName) == 'enabled'; } } return false; }
/** * Loop over all bottom reports and if callable call them with $as_html parameter, * if not output as is (string). * * @param bool $as_html */ static function printBottomReportsList($as_html = true) { $debug = eZDebug::instance(); $reportNames = array_keys($debug->bottomReportsList); foreach ($reportNames as $reportName) { if (is_callable($debug->bottomReportsList[$reportName])) { echo call_user_func_array($debug->bottomReportsList[$reportName], array($as_html)); } else { echo $debug->bottomReportsList[$reportName]; } } }
/** * Reset accumulators values so far: either a single one or all of them. * NB: also clears the ezdebug accumulators */ public static function accumulatorReset($val = null) { if ($val === null) { self::$timeAccumulatorList = array(); if (eZPerfLoggerDebug::isDebugEnabled()) { $debug = eZDebug::instance(); $debug->TimeAccumulatorList = array(); } } else { unset(self::$timeAccumulatorList[$val]); } }
static function printBottomReportsList() { $debug = eZDebug::instance(); $reportNames = array_keys($debug->bottomReportsList); foreach ($reportNames as $reportName) { echo $debug->bottomReportsList[$reportName]; } }
function akismetInformationExtractor($version) { $ini = eZINI::instance('akismet.ini'); $infoExtractors = $ini->variable('InformationExtractorSettings', 'ExtractableClasses'); $debug = eZDebug::instance(); $comment = array(); $contentObject = $version->attribute('contentobject'); $classIdentifier = $contentObject->attribute('class_identifier'); //Do not uncomment the line below - it could generate false spam warnings //$comment['type'] = $classIdentifier; if (!in_array($classIdentifier, $infoExtractors)) { $debug->writeWarning('No Akismet content object information extractor configured for content class with identifier: ' . $classIdentifier); return false; } $iniGroup = $classIdentifier . '_AkismetSettings'; if (!$ini->hasGroup($iniGroup)) { $debug->writeWarning('No configuration group in upload.ini for class identifier %class_identifier: ' . $classIdentifier); return false; } $authorIdentifier = $ini->variable($classIdentifier . '_AkismetSettings', 'AuthorAttribute'); $emailIdentifier = $ini->variable($classIdentifier . '_AkismetSettings', 'EmailAttribute'); $websiteIdentifier = $ini->variable($classIdentifier . '_AkismetSettings', 'WebsiteAttribute'); $bodyIdentifier = $ini->variable($classIdentifier . '_AkismetSettings', 'BodyAttribute'); $attributeIdentifiers = array('author' => $authorIdentifier, 'email' => $emailIdentifier, 'website' => $websiteIdentifier, 'body' => $bodyIdentifier); $contentObjectAttributes = $contentObject->contentObjectAttributes(); $loopLenght = count($contentObjectAttributes); for ($i = 0; $i < $loopLenght; $i++) { if (in_array($contentObjectAttributes[$i]->attribute('contentclass_attribute_identifier'), array_values($attributeIdentifiers))) { $key = array_search($contentObjectAttributes[$i]->attribute('contentclass_attribute_identifier'), $attributeIdentifiers); if ($contentObjectAttributes[$i]->hasContent()) { $value = $contentObjectAttributes[$i]->attribute('content'); switch ($datatypeString = $contentObjectAttributes[$i]->attribute('data_type_string')) { case 'ezuser': if ($authorIdentifier == $emailIdentifier) { $comment['author'] = $value->attribute('login'); $comment['email'] = $value->attribute('email'); break; } else { if ($key == "author") { $comment[$key] = $value->attribute('login'); break; } else { $comment[$key] = $value->attribute('email'); break; } } break; case 'ezauthor': if ($authorIdentifier == $emailIdentifier) { foreach ($value as $author) { $comment['author'] = $author[0]['name']; $comment['email'] = $author[0]['email']; break; } } else { foreach ($value as $author) { if ($key == "author") { $comment[$key] = $author[0]['name']; break; } else { $comment[$key] = $author[0]['email']; break; } } } break; case 'ezxml': if ($value instanceof eZXMLText) { $outputHandler = $value->attribute('output'); $itemDescriptionText = $outputHandler->attribute('output_text'); $value = substr(strip_tags($itemDescriptionText), 0, 1000); } $comment[$key] = $value; break; default: $comment[$key] = $value; break; } unset($attributeIdentifiers[$key]); } else { $comment[$key] = false; } } } return $comment; }
$object = eZContentObject::fetch( $objectID ); if ( $object ) { // delay commits with passing false for $commit parameter // error logging is handled at ezfind level in case the indexing fails if ( $eZSolr->addObject( $object, false ) ) { $toRemoveIds[] = $lastEntryId; } else { $cli->error("\tIndexing object ID #$objectID failed"); } eZContentObject::clearCache(); eZDebug::instance()->reset(); $GLOBALS['debugOutput'] = ""; } $db->commit(); } if ( !empty($toRemoveIds) ) { $cli->output( "Removing" ); $paramInSQL = $db->generateSQLInStatement( $toRemoveIds, 'id' ); $db->query( "DELETE FROM ezpending_actions WHERE $paramInSQL" ); } // finish up with commit $eZSolr->commit();
function numqueries($cluster = false) { $num = -1; $type = ''; if ($cluster) { // are we in cluster mode? $ini = eZINI::instance('file.ini'); $handler = $ini->variable('ClusteringSettings', 'FileHandler'); if ($handler == 'eZDBFileHandler' || $handler == 'eZDFSFileHandler') { $type = preg_replace('/^eZDBFileHandler/', '', $ini->variable('ClusteringSettings', 'DBBackend')); $type = strtolower(preg_replace('/^Backend$/', '', $type)); $type .= '_cluster_query'; } } else { $ini = eZINI::instance(); // we cannot use $db->databasename() because we get the same for mysql and mysqli $type = preg_replace('/^ez/', '', $ini->variable('DatabaseSettings', 'DatabaseImplementation')); $type .= '_query'; } // read accumulator $debug = eZDebug::instance(); if (isset($debug->TimeAccumulatorList[$type])) { $num = $debug->TimeAccumulatorList[$type]['count']; } return $num; }
/** * Display a list of messages by parsing an ezdebug log file, including its rotated versions. * Now with support for "raw" version as well * * @author G. Giunta * @copyright (C) G. Giunta 2010-2016 * @license Licensed under GNU General Public License v2.0. See file license.txt * * @todo add support for user-selected start and end date (offset/limit?) * @todo add support for not showing older (rotated) logs */ $errormsg = 'File not found'; $data = array(); $logname = ''; // nb: this dir is calculated the same way as ezlog does $debug = eZDebug::instance(); $logfiles = $debug->logFiles(); foreach ($logfiles as $level => $file) { if ($file[1] == $Params['logfile'] . '.log') { $logfile = $file[0] . $file[1]; $logname = $Params['logfile']; if (file_exists($logfile)) { $errormsg = ''; /// @todo add support for if-modified-since, etag headers if ($Params['viewmode'] == 'raw') { $mdate = gmdate('D, d M Y H:i:s', filemtime($logfile)) . ' GMT'; header('Content-Type: text/plain'); header("Last-Modified: {$mdate}"); /// @todo this can be a DOS. Do not attempt it if filesize is too big for the browser too handle, or use 'tail -1000'... for ($i = eZdebug::maxLogrotateFiles(); $i > 0; $i--) { $archivelog = $logfile . ".{$i}";
private function debug( $string, $label, $level = eZDebug::LEVEL_DEBUG ) { if ( empty( $this->cli ) ) { $debug = eZDebug::instance(); $debug->write( $string, $level, $label ); } else { $label = date( DATE_ATOM ) . ' -- ' . $label; $this->cli->output( $label . " :" ); if ( is_object( $string ) || is_array( $string ) ) { $string = eZDebug::dumpVariable( $string ); } $this->cli->output( $string ); } }