summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjokkedk <joakim@jokke.dk>2008-06-18 20:49:16 +0000
committerjokkedk <joakim@jokke.dk>2008-06-18 20:49:16 +0000
commitebfc573ec57b50aca1d51be6e75918c4a137f72a (patch)
tree4cda47cd2c3977157170cd9a699d8173edd44270
parent5202cfb5f75fc958bd2ec04040e75542e74954bb (diff)
downloadwebgrind-ebfc573ec57b50aca1d51be6e75918c4a137f72a.zip
webgrind-ebfc573ec57b50aca1d51be6e75918c4a137f72a.tar.gz
webgrind-ebfc573ec57b50aca1d51be6e75918c4a137f72a.tar.bz2
#8 - Autodetecting profiler_output_name and profiler_output_dir
-rw-r--r--config.php48
-rw-r--r--index.php2
-rw-r--r--library/FileHandler.php4
3 files changed, 28 insertions, 26 deletions
diff --git a/config.php b/config.php
index 53dddae..226b214 100644
--- a/config.php
+++ b/config.php
@@ -6,23 +6,11 @@
* @author Joakim Nygård
*/
class Webgrind_Config{
- static $webgrindVersion = '0.71';
-
/**
* Automatically check if a newer version of webgrind is available for download
*/
static $checkVersion = true;
-
- /**
- * Regex that matches the trace files generated by xdebug
- */
- static $xdebugOutputFormat = '/^cachegrind\.out\.[0-9]+$/';
-
- /**
- * Directory to search for trace files
- */
- static $xdebugOutputDir = '/tmp/';
-
+
/**
* Writable dir for information storage
*/
@@ -33,19 +21,10 @@ class Webgrind_Config{
*/
static $preprocessedSuffix = '.prep';
- /**
- * Default timezone
- */
static $defaultTimezone = 'Europe/Copenhagen';
- /**
- * Date format
- */
static $dateFormat = 'Y-m-d H:i:s';
-
static $defaultCostformat = 'percent'; // 'percent', 'usec' or 'msec'
-
static $defaultFunctionPercentage = 90;
-
static $defaultHideInternalFunctions = false;
/**
@@ -56,5 +35,28 @@ class Webgrind_Config{
static $fileUrlFormat = 'index.php?op=fileviewer&file=%1$s&line=%2$d'; // Built in fileviewer
//static $fileUrlFormat = 'txmt://open/?url=file://%1$s&line=%2$d'; // Textmate
//static $fileUrlFormat = 'file://%1$s'; // ?
-
+
+
+
+ #########################
+ # BELOW NOT FOR EDITING #
+ #########################
+
+ static $webgrindVersion = '0.72';
+
+ /**
+ * Regex that matches the trace files generated by xdebug
+ */
+ static function xdebugOutputFormat() {
+ $outputName = ini_get('xdebug.profiler_output_name');
+ $outputName = '/^'.preg_replace('/(%[^%])+/', '[a-zA-Z0-9%_-]+$/', $outputName);
+ return $outputName;
+ }
+
+ /**
+ * Directory to search for trace files
+ */
+ static function xdebugOutputDir() {
+ return ini_get('xdebug.profiler_output_dir').'/';
+ }
}
diff --git a/index.php b/index.php
index af316f0..3ecc0a7 100644
--- a/index.php
+++ b/index.php
@@ -80,7 +80,7 @@ switch(get('op')){
$result['dataFile'] = $dataFile;
$result['invokeUrl'] = $reader->getHeader('cmd');
$result['breakdown'] = $breakdown;
- $result['mtime'] = date(Webgrind_Config::$dateFormat,filemtime(Webgrind_Config::$xdebugOutputDir.$dataFile));
+ $result['mtime'] = date(Webgrind_Config::$dateFormat,filemtime(Webgrind_Config::xdebugOutputDir().$dataFile));
echo json_encode($result);
break;
case 'callinfo_list':
diff --git a/library/FileHandler.php b/library/FileHandler.php
index 50920b6..ca518e4 100644
--- a/library/FileHandler.php
+++ b/library/FileHandler.php
@@ -23,7 +23,7 @@ class Webgrind_FileHandler{
private function __construct(){
// Get list of files matching the defined format
- $files = $this->getFiles(Webgrind_Config::$xdebugOutputFormat, Webgrind_Config::$xdebugOutputDir);
+ $files = $this->getFiles(Webgrind_Config::xdebugOutputFormat(), Webgrind_Config::xdebugOutputDir());
// Get list of preprocessed files
$prepFiles = $this->getFiles('/\\'.Webgrind_Config::$preprocessedSuffix.'$/', Webgrind_Config::$storageDir);
@@ -112,7 +112,7 @@ class Webgrind_FileHandler{
$r = new Webgrind_Reader($prepFile, $costFormat);
} catch (Exception $e){
// Preprocessed file does not exist or other error
- Webgrind_Preprocessor::parse(Webgrind_Config::$xdebugOutputDir.$file, $prepFile);
+ Webgrind_Preprocessor::parse(Webgrind_Config::xdebugOutputDir().$file, $prepFile);
$r = new Webgrind_Reader($prepFile, $costFormat);
}
return $r;