mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
#17630622 * 디버그 메시지 출력 코드 정리
* __DEBUG__ 상수의 기본 값(0)에서는 어떠한 메시지도 출력하지 않도록 변경 * __DEBUG__ 상수의 순차적 증가 값을 비트 값으로 변경 * config/config.inc.php 파일의 설정 값 보다 우선하는 config/config.user.inc.php 를 먼저 읽도록 추가 * DisplayHandler::_debugOutput()에서 debugPrint()를 사용하지 않도록 변경 git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5339 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
27431fb123
commit
2f2578e7f8
3 changed files with 196 additions and 162 deletions
|
|
@ -172,86 +172,33 @@
|
|||
|
||||
$end = getMicroTime();
|
||||
|
||||
if(__DEBUG_OUTPUT__ != 2 || (__DEBUG_OUTPUT__ == 2 && !version_compare(PHP_VERSION, '5.2.0', '>'))) {
|
||||
// debug string 작성 시작
|
||||
$buff = "\n\n** Debug at ".date('Y-m-d H:i:s')." ************************************************************\n";
|
||||
|
||||
// Request/Response 정보 작성
|
||||
$buff .= "\n- Request/ Response info\n";
|
||||
$buff .= sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s\n", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']?'?':'', $_SERVER['QUERY_STRING']);
|
||||
$buff .= sprintf("\tRequest method \t\t\t: %s\n", $_SERVER['REQUEST_METHOD']);
|
||||
$buff .= sprintf("\tResponse method \t\t: %s\n", Context::getResponseMethod());
|
||||
$buff .= sprintf("\tResponse contents size\t\t: %d byte\n", $this->getContentSize());
|
||||
|
||||
// DB 로그 작성
|
||||
if(__DEBUG__ > 1) {
|
||||
if($GLOBALS['__db_queries__']) {
|
||||
$buff .= "\n- DB Queries\n";
|
||||
$num = 0;
|
||||
foreach($GLOBALS['__db_queries__'] as $query) {
|
||||
$buff .= sprintf("\t%02d. %s (%0.6f sec)\n", ++$num, $query['query'], $query['elapsed_time']);
|
||||
if($query['result'] == 'Success') {
|
||||
$buff .= "\t Query Success\n";
|
||||
} else {
|
||||
$buff .= sprintf("\t Query $s : %d\n\t\t\t %s\n", $query['result'], $query['errno'], $query['errstr']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$buff .= "\n- Elapsed time\n";
|
||||
|
||||
if($GLOBALS['__db_elapsed_time__']) $buff .= sprintf("\tDB queries elapsed time\t\t: %0.5f sec\n", $GLOBALS['__db_elapsed_time__']);
|
||||
}
|
||||
|
||||
// 기타 로그 작성
|
||||
if(__DEBUG__==3) {
|
||||
$buff .= sprintf("\tclass file load elapsed time \t: %0.5f sec\n", $GLOBALS['__elapsed_class_load__']);
|
||||
$buff .= sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)\n", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']);
|
||||
$buff .= sprintf("\tXmlParse compile elapsed time\t: %0.5f sec\n", $GLOBALS['__xmlparse_elapsed__']);
|
||||
$buff .= sprintf("\tPHP elapsed time \t\t: %0.5f sec\n", $end-__StartTime__-$GLOBALS['__template_elapsed__']-$GLOBALS['__xmlparse_elapsed__']-$GLOBALS['__db_elapsed_time__']-$GLOBALS['__elapsed_class_load__']);
|
||||
|
||||
// 위젯 실행 시간 작성
|
||||
$buff .= sprintf("\n\tWidgets elapsed time \t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']);
|
||||
|
||||
// 레이아웃 실행 시간
|
||||
$buff .= sprintf("\n\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']);
|
||||
|
||||
// 위젯, 에디터 컴포넌트 치환 시간
|
||||
$buff .= sprintf("\n\tTrans widget&editor elapsed time: %0.5f sec\n\n", $GLOBALS['__trans_widget_editor_elapsed__']);
|
||||
}
|
||||
|
||||
// 전체 실행 시간 작성
|
||||
$buff .= sprintf("\tTotal elapsed time \t\t: %0.5f sec", $end-__StartTime__);
|
||||
}
|
||||
|
||||
if(__DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML') {
|
||||
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
|
||||
$buff = '허용되지 않은 IP 입니다. config/config.inc.php 파일의 __DEBUG_PROTECT_IP__ 상수 값을 자신의 IP로 변경하세요.';
|
||||
}
|
||||
return "<!--\r\n".$buff."\r\n-->";
|
||||
}
|
||||
|
||||
if(__DEBUG_OUTPUT__==0) debugPrint($buff, false);
|
||||
|
||||
// Firebug 콘솔 출력
|
||||
if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '5.2.0', '>')) {
|
||||
debugPrint(
|
||||
array('Request / Response info >>> '.Context::getResponseMethod().' / '.$_SERVER['REQUEST_METHOD'],
|
||||
array(
|
||||
array('Request URI', 'Request method', 'Response method', 'Response contents size'),
|
||||
array(
|
||||
sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']?'?':'', $_SERVER['QUERY_STRING']),
|
||||
$_SERVER['REQUEST_METHOD'],
|
||||
Context::getResponseMethod(),
|
||||
$this->getContentSize().' byte'
|
||||
)
|
||||
)
|
||||
),
|
||||
'TABLE'
|
||||
);
|
||||
if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '5.2.0', '>=')) {
|
||||
static $firephp;
|
||||
if(!isset($firephp)) $firephp = FirePHP::getInstance(true);
|
||||
|
||||
// 기타 로그 작성
|
||||
if(__DEBUG__ == 3 || __DEBUG__ == 1) {
|
||||
debugPrint(
|
||||
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
|
||||
$firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.');
|
||||
return;
|
||||
}
|
||||
|
||||
// 전체 실행 시간 출력, Request/Response info 출력
|
||||
if(__DEBUG__ & 2) {
|
||||
$firephp->fb(
|
||||
array('Request / Response info >>> '.$_SERVER['REQUEST_METHOD'].' / '.Context::getResponseMethod(),
|
||||
array(
|
||||
array('Request URI', 'Request method', 'Response method', 'Response contents size'),
|
||||
array(
|
||||
sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']?'?':'', $_SERVER['QUERY_STRING']),
|
||||
$_SERVER['REQUEST_METHOD'],
|
||||
Context::getResponseMethod(),
|
||||
$this->getContentSize().' byte'
|
||||
)
|
||||
)
|
||||
),
|
||||
'TABLE'
|
||||
);
|
||||
$firephp->fb(
|
||||
array('Elapsed time >>> Total : '.sprintf('%0.5f sec', $end - __StartTime__),
|
||||
array(array('DB queries', 'class file load', 'Template compile', 'XmlParse compile', 'PHP', 'Widgets', 'Trans widget&editor'),
|
||||
array(
|
||||
|
|
@ -269,21 +216,95 @@
|
|||
);
|
||||
}
|
||||
|
||||
// DB 쿼리 로그
|
||||
if(__DEBUG__ > 1) {
|
||||
// DB 쿼리 내역 출력
|
||||
if(__DEBUG__ & 4) {
|
||||
$queries_output = array(array('Query', 'Elapsed time', 'Result'));
|
||||
foreach($GLOBALS['__db_queries__'] as $query) {
|
||||
array_push($queries_output, array($query['query'], sprintf('%0.5f', $query['elapsed_time']), $query['result']));
|
||||
}
|
||||
debugPrint(
|
||||
array('DB Queries >>> '.count($GLOBALS['__db_queries__']).' Queries, '.sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']), $queries_output),
|
||||
$firephp->fb(
|
||||
array(
|
||||
'DB Queries >>> '.count($GLOBALS['__db_queries__']).' Queries, '.sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
|
||||
$queries_output
|
||||
),
|
||||
'TABLE'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// 파일 및 HTML 주석으로 출력
|
||||
} else {
|
||||
// debug string 작성 시작
|
||||
$buff = "** Debug at ".date('Y-m-d H:i:s').str_repeat('*', 60)."\n";
|
||||
|
||||
// 전체 실행 시간 출력, Request/Response info 출력
|
||||
if(__DEBUG__ & 2) {
|
||||
// Request/Response 정보 작성
|
||||
$buff .= "\n- Request/ Response info\n";
|
||||
$buff .= sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s\n", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']?'?':'', $_SERVER['QUERY_STRING']);
|
||||
$buff .= sprintf("\tRequest method \t\t\t: %s\n", $_SERVER['REQUEST_METHOD']);
|
||||
$buff .= sprintf("\tResponse method \t\t: %s\n", Context::getResponseMethod());
|
||||
$buff .= sprintf("\tResponse contents size\t\t: %d byte\n", $this->getContentSize());
|
||||
|
||||
// 전체 실행 시간
|
||||
$buff .= sprintf("\n- Total elapsed time : %0.5f sec\n", $end-__StartTime__);
|
||||
|
||||
$buff .= sprintf("\tclass file load elapsed time \t: %0.5f sec\n", $GLOBALS['__elapsed_class_load__']);
|
||||
$buff .= sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)\n", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']);
|
||||
$buff .= sprintf("\tXmlParse compile elapsed time\t: %0.5f sec\n", $GLOBALS['__xmlparse_elapsed__']);
|
||||
$buff .= sprintf("\tPHP elapsed time \t\t: %0.5f sec\n", $end-__StartTime__-$GLOBALS['__template_elapsed__']-$GLOBALS['__xmlparse_elapsed__']-$GLOBALS['__db_elapsed_time__']-$GLOBALS['__elapsed_class_load__']);
|
||||
|
||||
// 위젯 실행 시간 작성
|
||||
$buff .= sprintf("\n\tWidgets elapsed time \t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']);
|
||||
|
||||
// 레이아웃 실행 시간
|
||||
$buff .= sprintf("\n\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']);
|
||||
|
||||
// 위젯, 에디터 컴포넌트 치환 시간
|
||||
$buff .= sprintf("\n\tTrans widget&editor elapsed time: %0.5f sec\n", $GLOBALS['__trans_widget_editor_elapsed__']);
|
||||
}
|
||||
|
||||
// DB 로그 작성
|
||||
if(__DEBUG__ & 4) {
|
||||
if($GLOBALS['__db_queries__']) {
|
||||
$buff .= sprintf("\n- DB Queries : %d Queries. %0.5f sec\n", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']);
|
||||
$num = 0;
|
||||
|
||||
foreach($GLOBALS['__db_queries__'] as $query) {
|
||||
$buff .= sprintf("\t%02d. %s\n\t\t%0.6f sec. ", ++$num, $query['query'], $query['elapsed_time']);
|
||||
if($query['result'] == 'Success') {
|
||||
$buff .= "Query Success\n";
|
||||
} else {
|
||||
$buff .= sprintf("Query $s : %d\n\t\t\t %s\n", $query['result'], $query['errno'], $query['errstr']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// HTML 주석으로 출력
|
||||
if(__DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML') {
|
||||
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
|
||||
$buff = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php';
|
||||
}
|
||||
return "<!--\r\n".$buff."\r\n-->";
|
||||
}
|
||||
|
||||
// 파일에 출력
|
||||
if(__DEBUG_OUTPUT__ == 0) {
|
||||
$debug_file = _XE_PATH_.'files/_debug_message.php';
|
||||
$debug_output = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($debug_output, true));
|
||||
|
||||
if($display_option === true) $debug_output = str_repeat('=', 40)."\n".$debug_output.str_repeat('-', 40);
|
||||
$debug_output = "\n<?php\n/*".$debug_output."*/\n?>\n";
|
||||
|
||||
if(@!$fp = fopen($debug_file, 'a')) return;
|
||||
fwrite($fp, $debug_output);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief RequestMethod에 맞춰 헤더 출력
|
||||
***/
|
||||
|
|
@ -330,4 +351,4 @@
|
|||
header("Pragma: no-cache");
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue