Changeset 1352
- Timestamp:
- 05/13/06 14:08:13 (3 years ago)
- Files:
-
- trunk/data/web/sf/css/sf_web_debug (moved) (moved from trunk/data/web/sf/css/sf_debug_stats)
- trunk/data/web/sf/css/sf_web_debug/main.css (modified) (6 diffs)
- trunk/data/web/sf/images/sf_web_debug (moved) (moved from trunk/data/web/sf/images/sf_debug_stats)
- trunk/data/web/sf/images/sf_web_debug/close.png (modified) (previous)
- trunk/data/web/sf/images/sf_web_debug/comment.png (added)
- trunk/data/web/sf/images/sf_web_debug/config.png (added)
- trunk/data/web/sf/images/sf_web_debug/database.png (added)
- trunk/data/web/sf/images/sf_web_debug/error.png (modified) (previous)
- trunk/data/web/sf/images/sf_web_debug/info.png (modified) (previous)
- trunk/data/web/sf/images/sf_web_debug/memory.png (added)
- trunk/data/web/sf/images/sf_web_debug/reload.png (modified) (previous)
- trunk/data/web/sf/images/sf_web_debug/sf.png (added)
- trunk/data/web/sf/images/sf_web_debug/time.png (added)
- trunk/data/web/sf/images/sf_web_debug/warning.png (modified) (previous)
- trunk/data/web/sf/js/sf_web_debug (added)
- trunk/data/web/sf/js/sf_web_debug/main.js (added)
- trunk/lib/debug/sfDebug.class.php (modified) (1 diff)
- trunk/lib/debug/sfWebDebug.class.php (modified) (13 diffs)
- trunk/lib/exception/sfException.class.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/data/web/sf/css/sf_web_debug/main.css
r1187 r1352 1 #sfWebDebug 2 { 3 padding: 0; 4 margin: 0; 5 font-family: Arial, sans-serif; 6 font-size: 12px; 7 color: #333; 8 text-align: left; 9 line-height: 12px; 10 } 11 12 #sfWebDebug a, #sfWebDebug a:hover 13 { 14 text-decoration: none; 15 border: none; 16 background-color: #eee; 17 color: #000; 18 } 19 20 #sfWebDebug img 21 { 22 border: 0; 23 } 24 25 #sfWebDebugBar 26 { 27 position: fixed; 28 margin: 0; 29 padding: 1px 0; 30 right: 0px; 31 top: 0px; 32 opacity: 0.80; 33 filter: alpha(opacity:80); 34 z-index: 10000; 35 background-color: #ddd; 36 } 37 38 #sfWebDebugBar a 39 { 40 background-color: #ddd; 41 } 42 43 #sfWebDebugBar img 44 { 45 vertical-align: middle; 46 } 47 48 #sfWebDebugBar .menu 49 { 50 padding: 5px; 51 display: inline; 52 } 53 54 #sfWebDebugBar .menu li 55 { 56 display: inline; 57 list-style: none; 58 padding: 0 5px; 59 border-right: 1px solid #aaa; 60 } 61 62 #sfWebDebugBar .menu li.last 63 { 64 padding: 0; 65 border: 0; 66 } 67 68 #sfWebDebugShortMessages li 69 { 70 margin-bottom: 10px; 71 padding: 5px; 72 background-color: #ddd; 73 } 74 75 #sfWebDebugShortMessages li 76 { 77 list-style: none; 78 } 79 80 #sfWebDebugDetails 81 { 82 margin-right: 7px; 83 } 84 85 #sfWebDebug pre 86 { 87 line-height: 1.3; 88 margin-bottom: 10px; 89 } 90 91 #sfWebDebug h1 92 { 93 font-size: 16px; 94 font-weight: bold; 95 margin-bottom: 20px; 96 padding: 0; 97 border: 0px; 98 background-color: #eee; 99 } 100 101 #sfWebDebug h2 102 { 103 font-size: 14px; 104 font-weight: bold; 105 margin: 10px 0; 106 padding: 0; 107 border: 0px; 108 background: none; 109 } 110 111 #sfWebDebug .top 112 { 113 position: absolute; 114 left: 0px; 115 top: 0px; 116 width: 100%; 117 padding: 10px; 118 z-index: 9999; 119 background-color: #efefef; 120 border-bottom: 1px solid #aaa; 121 } 122 123 #sfWebDebugLog 124 { 125 margin: 0; 126 padding: 3px; 127 font-size: 11px; 128 } 129 130 #sfWebDebugLogMenu li 131 { 132 display: inline; 133 list-style: none; 134 padding: 0 5px; 135 border-right: 1px solid #aaa; 136 } 137 138 #sfWebDebugConfigSummary 139 { 140 display: inline; 141 padding: 5px; 142 background-color: #ddd; 143 border: 1px solid #aaa; 144 margin: 20px 0; 145 } 146 147 #sfWebDebugConfigSummary li 148 { 149 list-style: none; 150 display: inline; 151 padding: 0 5px; 152 border-right: 1px solid #aaa; 153 } 154 155 #sfWebDebugConfigSummary li.last 156 { 157 padding: 0; 158 border: 0; 159 } 160 161 #sfWebDebug .info 162 { 163 background-color: #9f9; 164 } 165 166 #sfWebDebug .warning 167 { 168 background-color: orange; 169 } 170 171 #sfWebDebug .error 172 { 173 background-color: #f99; 174 } 175 176 1 177 #sfStatsBase 2 178 { … … 26 202 text-decoration: none; 27 203 border: none; 28 background-color: none;204 background-color: #eee; 29 205 color: #00f; 30 206 } … … 91 267 .ison 92 268 { 93 color: green; 269 color: #3f3; 270 margin-right: 5px; 94 271 } 95 272 96 273 .isoff 97 274 { 98 color: red; 99 } 100 101 .float 102 { 103 float: right; 104 clear: right; 105 } 106 107 .bold 108 { 109 font-weight: bold; 275 color: #f33; 276 margin-right: 5px; 277 text-decoration: line-through; 110 278 } 111 279 … … 117 285 width: 100%; 118 286 position: absolute; 119 }120 121 #sfStatsLog122 {123 margin: 0;124 padding: 3px;125 padding-bottom: 10px;126 font-family:arial;127 font-size:11px;128 border: 1px solid #aaa;129 background-color: #eee;130 color: #333;131 287 } 132 288 … … 182 338 } 183 339 184 .sf StatsCache340 .sfWebDebugCache 185 341 { 186 342 padding: 0; … … 197 353 } 198 354 199 #sfStatsLogs tr.sf StatsRedtd355 #sfStatsLogs tr.sfWebDebugError td 200 356 { 201 357 background-color: #f00; 202 358 } 203 359 204 #sfStatsLogs tr.sf StatsOrangetd360 #sfStatsLogs tr.sfWebDebugWarning td 205 361 { 206 362 background-color: orange; 207 363 } 208 209 #sfStatsShortMessages210 {211 padding: 3px;212 background-color: #ddd;213 }trunk/lib/debug/sfDebug.class.php
r1351 r1352 19 19 class sfDebug 20 20 { 21 public static function phpInfoAsArray() 22 { 23 $values = array( 24 'php' => phpversion(), 25 'os' => php_uname(), 26 'extensions' => get_loaded_extensions(), 27 ); 28 29 return $values; 30 } 31 21 32 public static function globalsAsArray() 22 33 { trunk/lib/debug/sfWebDebug.class.php
r1300 r1352 25 25 $types = array(), 26 26 $last_time_log = -1, 27 $base_image_path = '/sf/images/sf_ debug_stats';27 $base_image_path = '/sf/images/sf_web_debug'; 28 28 29 29 private static … … 72 72 73 73 // register our css and js 74 $this->context->getResponse()->addJavascript('/sf/js/ prototype/prototype');75 $this->context->getResponse()->addStylesheet('/sf/css/sf_ debug_stats/main');74 $this->context->getResponse()->addJavascript('/sf/js/sf_web_debug/main'); 75 $this->context->getResponse()->addStylesheet('/sf/css/sf_web_debug/main'); 76 76 } 77 77 … … 166 166 $result = ''; 167 167 168 // total time elapsed169 $total_time = 0;170 if (sfConfig::get('sf_debug'))171 {172 $total_time = (microtime(true) - sfConfig::get('sf_timer_start')) * 1000;173 $total_time = sprintf(($total_time <= 1) ? '%.2f' : '%.0f', $total_time);174 }175 176 // memory used177 $total_memory = 0;178 if (sfConfig::get('sf_debug') && function_exists('memory_get_usage'))179 {180 $total_memory = sprintf('%.1f', (memory_get_usage() / 1024));181 }182 183 168 // max priority 184 169 $log_image = ''; … … 198 183 } 199 184 } 200 201 // short messages202 $short_messages = '';203 if ($this->short_log)204 {205 $short_messages = '<div id="sfStatsShortMessages">» '.implode('<br />» ', $this->short_log).'</div>';206 }207 208 $result .= '209 <div class="sfStats" id="sfStats'.ucfirst($log_image).'">210 '.$this->displayMenu($log_image).'211 <div id="sfStatsDetails">'.$this->displayCurrentConfig().'</div>212 <div id="sfStatsTime">processed in <strong>'.$total_time.'</strong> ms</div>213 '.($total_memory ? '<div id="sfStatsMemory">memory: <strong>'.$total_memory.'</strong> KB</div>' : '').'214 '.$short_messages.'215 </div>216 ';217 185 218 186 if ($sf_logging_active) … … 233 201 if ($logEntry->getPriority() >= 6) 234 202 { 235 $class = 'Green';236 203 $priority = 'info'; 237 204 } 238 205 else if ($logEntry->getPriority() >= 4) 239 206 { 240 $class = 'Orange';241 207 $priority = 'warning'; 242 208 } 243 209 else 244 210 { 245 $class = 'Red';246 211 $priority = 'error'; 247 212 } … … 255 220 if ($logEntry->getDebugStack()) 256 221 { 257 $debug_info .= ' <a href="#" onclick=" Element.toggle(\'debug_'.$line_nb.'\'); return false;">'.image_tag($this->base_image_path.'/toggle.gif').'</a><div class="sfStatsDebugInfo" id="debug_'.$line_nb.'" style="display:none">';222 $debug_info .= ' <a href="#" onclick="sfWebDebugToggle(\'debug_'.$line_nb.'\'); return false;">'.image_tag($this->base_image_path.'/toggle.gif').'</a><div class="sfStatsDebugInfo" id="debug_'.$line_nb.'" style="display:none">'; 258 223 foreach ($logEntry->getDebugStack() as $i => $log_line) 259 224 { … … 267 232 268 233 ++$line_nb; 269 $logs .= sprintf("<tr class='sf Stats%s %s'><td>%s</td><td>%s</td><td>+%s </td><td><span class=\"sfStatsLogType\">%s</span></td><td>%s%s</td></tr>\n", $class, $logEntry->getType(), $line_nb, image_tag($this->base_image_path.'/'.$priority.'.png', 'align=middle'), $logEntry->getElapsedTime(), $type, $log, $debug_info);234 $logs .= sprintf("<tr class='sfWebDebugLogLine sfWebDebug%s %s'><td>%s</td><td>%s</td><td>+%s </td><td><span class=\"sfStatsLogType\">%s</span></td><td>%s%s</td></tr>\n", ucfirst($priority), $logEntry->getType(), $line_nb, image_tag($this->base_image_path.'/'.$priority.'.png'), $logEntry->getElapsedTime(), $type, $log, $debug_info); 270 235 } 271 236 $logs .= '</table>'; 272 273 $result .= javascript_tag('274 function toggleMessages(myclass)275 {276 elements = document.getElementsByClassName(myclass);277 for (i = 0, x = elements.length; i < x; ++i)278 {279 Element.toggle(elements[i]);280 }281 }282 ');283 237 284 238 ksort($this->types); … … 286 240 foreach ($this->types as $type => $nb) 287 241 { 288 $types[] = '<a id="'.$type.'" href="#" onclick="toggleMessages(\''.$type.'\'); return false;">'.$type."</a>\n"; 289 } 290 291 $result .= ' 292 <div id="sfStatsLogMain" style="display: none"> 293 <div id="sfStatsLogMenu"> 294 <div class="float">'. 295 implode(' - ', $types).' 296 <a href="#" onclick="toggleMessages(\'sfStatsGreen\')">'.image_tag($this->base_image_path.'/info.png', 'align=middle').'</a> 297 <a href="#" onclick="Element.hide(\'sfStatsLogMain\')">'.image_tag($this->base_image_path.'/close.png', 'align=middle').'</a> 298 </div> 299 <strong>Log messages</strong> 300 </div> 301 <div id="sfStatsLog">'.$logs.'</div> 242 $types[] = '<a id="sfWebDebug'.$type.'" href="#" onclick="sfWebDebugToggleMessages(\''.$type.'\')">'.$type.'</a>'; 243 } 244 } 245 246 // ignore cache link 247 $cacheLink = ''; 248 if (sfConfig::get('sf_debug') && sfConfig::get('sf_cache')) 249 { 250 $self_url = $_SERVER['PHP_SELF'].((strpos($_SERVER['PHP_SELF'], 'sf_ignore_cache') === false) ? '?sf_ignore_cache=1' : ''); 251 $cacheLink = '<a href="'.$self_url.'" title="reload and ignore cache"><img src="'.$this->base_image_path.'/reload.png" /></a>'; 252 } 253 254 // logging information 255 $logLink = ''; 256 if (sfConfig::get('sf_logging_active')) 257 { 258 $logLink = '<li><a href="#" onclick="document.getElementById(\'sfWebDebugConfig\').style.display=\'none\';sfWebDebugToggle(\'sfWebDebugLog\')"><img src="'.$this->base_image_path.'/comment.png" /> logs & msgs</a></li>'; 259 } 260 261 // database information 262 $dbInfo = ''; 263 if (null !== ($nb = $this->getDatabaseRequestNumber())) 264 { 265 $dbInfo = '<li><img src="'.$this->base_image_path.'/database.png" /> '.$nb.'</li>'; 266 } 267 268 // memory used 269 $memoryInfo = ''; 270 if (sfConfig::get('sf_debug') && function_exists('memory_get_usage')) 271 { 272 $total_memory = sprintf('%.1f', (memory_get_usage() / 1024)); 273 $memoryInfo = '<li><img src="'.$this->base_image_path.'/memory.png" /> '.$total_memory.' KB</li>'; 274 } 275 276 // total time elapsed 277 $timeInfo = ''; 278 if (sfConfig::get('sf_debug')) 279 { 280 $total_time = (microtime(true) - sfConfig::get('sf_timer_start')) * 1000; 281 $total_time = sprintf(($total_time <= 1) ? '%.2f' : '%.0f', $total_time); 282 $timeInfo = '<li class="last"><img src="'.$this->base_image_path.'/time.png" /> '.$total_time.' ms</li>'; 283 } 284 285 // short log messages 286 $short_messages = ''; 287 if ($this->short_log) 288 { 289 $short_messages = '<ul id="sfWebDebugShortMessages"><li>» '.implode('</li><li>» ', $this->short_log).'</li></ul>'; 290 } 291 292 // logs 293 $logInfo = ''; 294 if ($sf_logging_active) 295 { 296 $logInfo = $short_messages.' 297 <ul id="sfWebDebugLogMenu"> 298 <li><a href="#" onclick="sfWebDebugToggleAllLogLines(true, \'sfWebDebugLogLine\')">[all]</a></li> 299 <li><a href="#" onclick="sfWebDebugToggleAllLogLines(false, \'sfWebDebugLogLine\')">[none]</a></li> 300 <li><a href="#" onclick="sfWebDebugShowOnlyLogLines(\'info\')"><img src="'.$this->base_image_path.'/info.png" /></a></li> 301 <li><a href="#" onclick="sfWebDebugShowOnlyLogLines(\'warning\')"><img src="'.$this->base_image_path.'/warning.png" /></a></li> 302 <li><a href="#" onclick="sfWebDebugShowOnlyLogLines(\'error\')"><img src="'.$this->base_image_path.'/error.png" /></a></li> 303 <li>'.implode("</li>\n<li>", $types).'</li> 304 </ul> 305 <div id="sfWebDebugLog">'.$logs.'</div> 306 '; 307 } 308 309 $result .= ' 310 <div id="sfWebDebug"> 311 <div id="sfWebDebugBar"> 312 <a href="#" onclick="sfWebDebugToggleMenu()"><img src="'.$this->base_image_path.'/sf.png" /></a> 313 <ul id="sfWebDebugDetails" class="menu"> 314 <li><a href="#" onclick="document.getElementById(\'sfWebDebugLog\').style.display=\'none\';sfWebDebugToggle(\'sfWebDebugConfig\')"><img src="'.$this->base_image_path.'/config.png" /> vars & config</a></li> 315 '.$cacheLink.' 316 '.$logLink.' 317 '.$dbInfo.' 318 '.$memoryInfo.' 319 '.$timeInfo.' 320 </ul> 321 <a href="#" onclick="document.getElementById(\'sfWebDebug\').style.display=\'none\';"><img src="'.$this->base_image_path.'/close.png" /></a> 302 322 </div> 303 '; 304 } 305 306 return '<div id="sfStatsBase">'.$result.'</div>'; 307 } 308 309 private function displayMenu($log_image) 310 { 311 $result = '<div id="sfStatsRightMenu">'; 312 313 if (sfConfig::get('sf_logging_active')) 314 { 315 $result .= '<a href="#" onclick="Element.show(\'sfStatsLogMain\'); return false;">'.image_tag($this->base_image_path.'/'.$log_image.'.png', 'align=middle').'</a> '; 316 } 317 318 if (sfConfig::get('sf_debug') && sfConfig::get('sf_cache')) 319 { 320 $self_url = $_SERVER['PHP_SELF'].((strpos($_SERVER['PHP_SELF'], 'sf_ignore_cache') === false) ? '?sf_ignore_cache=1' : ''); 321 $result .= '<a href="'.$self_url.'" title="reload and ignore cache">'.image_tag($this->base_image_path.'/reload.png', 'align=middle').'</a>'; 322 } 323 324 $result .= ' 325 <a href="#" onclick="Element.hide(\'sfStats'.ucfirst($log_image).'\'); return false;">'.image_tag($this->base_image_path.'/close.png', 'align=middle').'</a> 323 324 <div id="sfWebDebugLog" class="top" style="display: none"> 325 <h1>Log and debug messages</h1> 326 '.$logInfo.' 327 </div> 328 329 <div id="sfWebDebugConfig" class="top" style="display: none"> 330 <h1>Configuration and request variables</h1> 331 '.$this->getCurrentConfigAsHtml().' 332 </div> 326 333 </div> 327 <div id="sfStatsLeftMenu"><a href="#" class="bold" onclick="Element.toggle(\'sfStatsDetails\', \'sfStatsTime\'); return false;">symfony</a></div>328 334 '; 329 335 … … 331 337 } 332 338 333 private function displayCurrentConfig()339 private function getCurrentConfigAsHtml() 334 340 { 335 341 $config = array( … … 343 349 'tidy' => (extension_loaded('tidy')) ? 'on' : 'off', 344 350 'syck' => (extension_loaded('syck')) ? 'on' : 'off', 345 'memusage' => (function_exists('memory_get_usage')) ? 'on' : 'off'346 351 ); 347 352 348 $result = ' ';353 $result = '<ul id="sfWebDebugConfigSummary">'; 349 354 foreach ($config as $key => $value) 350 355 { 351 $result .= '<div class="is'.$value.'"><span class="float bold">['.$value.']</span>'.$key.'</div>'; 352 } 353 356 $result .= '<li class="is'.$value.''.($key == 'syck' ? ' last' : '').'">'.$key.'</li>'; 357 } 358 $result .= '</ul>'; 359 360 $context = sfContext::getInstance(); 361 $result .= $this->formatArrayAsHtml('request', sfDebug::requestAsArray($context->getRequest())); 362 $result .= $this->formatArrayAsHtml('response', sfDebug::responseAsArray($context->getResponse())); 363 $result .= $this->formatArrayAsHtml('settings', sfDebug::settingsAsArray()); 364 $result .= $this->formatArrayAsHtml('globals', sfDebug::globalsAsArray()); 365 $result .= $this->formatArrayAsHtml('php', sfDebug::phpInfoAsArray()); 366 367 return $result; 368 } 369 370 private function formatArrayAsHtml($id, $values) 371 { 372 $id = ucfirst(strtolower($id)); 373 $content = ' 374 <h2>'.$id.' <a href="#" onclick="sfWebDebugToggle(\'sfWebDebug'.$id.'\')"><img src="'.$this->base_image_path.'/toggle.gif" /></a></h2> 375 <div id="sfWebDebug'.$id.'" style="display: none"><pre>'.sfYaml::Dump($values).'</pre></div> 376 '; 377 378 return $content; 379 } 380 381 public function getDatabaseRequestNumber() 382 { 354 383 if (sfConfig::get('sf_debug')) 355 384 { … … 364 393 if (method_exists($con, 'getNumQueriesExecuted')) 365 394 { 366 $result .= '<div><span class="float bold">['.$con->getNumQueriesExecuted().']</span>db requests</div>';395 return $con->getNumQueriesExecuted(); 367 396 } 368 397 } … … 373 402 } 374 403 375 return $result;404 return null; 376 405 } 377 406 … … 393 422 $retval = ' 394 423 <div id="main_'.$id.'" class="sfWebDebugActionCache" style="border: 1px solid '.$border_color.'"> 395 <div id="sub_main_'.$id.'" class="sf StatsCache" style="background-color: '.$bg_color.'; border-right: 1px solid '.$border_color.'; border-bottom: 1px solid '.$border_color.';">396 <div style="height: 16px; padding: 2px"><a href="#" onclick=" Element.toggle(\''.$id.'\'); return false;"><strong>cache information</strong></a> <a href="#" onclick="Element.hide(\'sub_main_'.$id.'\'); document.getElementById(\'main_'.$id.'\').style.border = \'none\'; return false;">'.image_tag($this->base_image_path.'/close.png', 'align=middle').'</a> </div>424 <div id="sub_main_'.$id.'" class="sfWebDebugCache" style="background-color: '.$bg_color.'; border-right: 1px solid '.$border_color.'; border-bottom: 1px solid '.$border_color.';"> 425 <div style="height: 16px; padding: 2px"><a href="#" onclick="sfWebDebugToggle(\''.$id.'\'); return false;"><strong>cache information</strong></a> <a href="#" onclick="Element.hide(\'sub_main_'.$id.'\'); document.getElementById(\'main_'.$id.'\').style.border = \'none\';">'.image_tag($this->base_image_path.'/close.png').'</a> </div> 397 426 <div style="padding: 2px; display: none" id="'.$id.'"> 398 427 [uri] '.$internalUri.'<br /> trunk/lib/exception/sfException.class.php
r1351 r1352 182 182 { 183 183 $context = sfContext::getInstance(); 184 $settingsTable = $this->formatArrayAs Table(sfDebug::settingsAsArray());185 $requestTable = $this->formatArrayAs Table(sfDebug::requestAsArray($context->getRequest()));186 $responseTable = $this->formatArrayAs Table(sfDebug::responseAsArray($context->getResponse()));187 $globalsTable = $this->formatArrayAs Table(sfDebug::globalsAsArray());184 $settingsTable = $this->formatArrayAsHtml(sfDebug::settingsAsArray()); 185 $requestTable = $this->formatArrayAsHtml(sfDebug::requestAsArray($context->getRequest())); 186 $responseTable = $this->formatArrayAsHtml(sfDebug::responseAsArray($context->getResponse())); 187 $globalsTable = $this->formatArrayAsHtml(sfDebug::globalsAsArray()); 188 188 } 189 189 … … 197 197 } 198 198 199 private function formatArrayAs Table($values)199 private function formatArrayAsHtml($values) 200 200 { 201 201 return '<pre>'.sfYaml::Dump($values).'</pre>';