| 제목 | debug용 헬퍼. | ||
|---|---|---|---|
| 글쓴이 | 듬직이 | 작성시각 | 2009/09/27 12:47:04 |
|
|
|||
|
firephp를 사용하지 않으시는 분들은 앞부분에 firephp를 삭제 하시고 사용하세요. 사용법 :
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* firephp
*
* @param $var array, string, integer
* @type string : "log", "warn", "error"
*/
function firephp($value, $type = 'log')
{
if( $type != 'log' AND $type != 'warn' AND $type != 'error')
{
$type = 'warn';
}
$CI =& get_instance();
$CI->firephp->{$type}($value);
}
//------------------------------------------------------------------------------
/**
* firephp
*
* @type string : log, warn, error
*/
function firephp_last_query($type = 'log')
{
if( $type != 'log' AND $type != 'warn' AND $type != 'error')
{
$type = 'warn';
}
$CI =& get_instance();
$CI->firephp->{$type}($CI->db->last_query());
}
//------------------------------------------------------------------------------
/**
* Outputs the query result
*
* @type string : log, warn, error
*/
function firephp_session($type = 'log')
{
if( $type != 'log' AND $type != 'warn' AND $type != 'error')
{
$type = 'warn';
}
$CI =& get_instance();
$CI->firephp->{$type}($CI->session->all_userdata());
}
//------------------------------------------------------------------------------
/**
* Outputs an array or variable
*
* @param $var array, string, integer
* @return string
*/
function debug_var($var = '')
{
echo _before();
if (is_array($var))
{
print_r($var);
}
else
{
echo $var;
}
echo _after();
}
//------------------------------------------------------------------------------
/**
* Outputs the last query
*
* @return string
*/
function debug_last_query()
{
$CI =& get_instance();
echo _before();
echo $CI->db->last_query();
echo _after();
}
//------------------------------------------------------------------------------
/**
* Outputs the query result
*
* @param $query object
* @return string
*/
function debug_query_result($query = '')
{
echo _before();
print_r($query->result_array());
echo _after();
}
//------------------------------------------------------------------------------
/**
* Outputs all session data
*
* @return string
*/
function debug_session()
{
$CI =& get_instance();
echo _before();
print_r($CI->session->all_userdata());
echo _after();
}
//------------------------------------------------------------------------------
/**
* Logs a message or var
*
* @param $message array, string, integer
* @return string
*/
function debug_log($message = '')
{
is_array($message) ? log_message('debug', print_r($message)) : log_message('debug', $message);
}
//------------------------------------------------------------------------------
/**
* _before
*
* @return string
*/
function _before()
{
$before = '<div style="padding:10px 20px 10px 20px; background-color:#fbe6f2; border:1px solid #d893a1; color: #000; font-size: 12px;>'."\n";
$before .= '<h5 style="font-family:verdana,sans-serif; font-weight:bold; font-size:18px;">Debug Helper Output</h5>'."\n";
$before .= '<pre>'."\n";
return $before;
}
//------------------------------------------------------------------------------
/**
* _after
*
* @return string
*/
function _after()
{
$after = '</pre>'."\n";
$after .= '</div>'."\n";
return $after;
}
//------------------------------------------------------------------------------
firephp 설치 참고 : http://gyuha.tistory.com/271 참고소스 : http://codeigniter.com/forums/viewthread/130302/#When:06:42:58Z |
|||
| 태그 | debug,firephp | ||
| 첨부파일 |
debug_helper.php (3.4 KB) |
||
| 다음글 | controllers 하위폴더 생성 (1) | ||
| 이전글 | 한글 랭귀지 팩 (10) | ||
|
변종원(웅파)
/
2009/09/28 09:40:33 /
추천
0
|
|
최용운
/
2009/09/28 12:34:08 /
추천
0
오 . .멋진데요 ? firebug 이름을 따라했나보네요 .
|
|
탱크
/
2011/03/27 15:37:59 /
추천
0
Firefox 4.0 에서는 안되나봐요~
전 나오지 않네요 ^^(혹 저만 안되는건가?) Issues with trunk Firefox for Firebug: http://getfirebug.com/knownissues 아직 호환이 될려면 시간이 필요한건가? |
감사합니다. ^^