mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Merge pull request #581 from kijin/pr/debug-error-msg
에러 로그 분량을 줄일 수 있는 옵션 추가
This commit is contained in:
commit
682a041aa4
8 changed files with 31 additions and 13 deletions
|
|
@ -88,6 +88,7 @@ return array(
|
|||
'display_type' => 'comment',
|
||||
'display_content' => array(),
|
||||
'display_to' => 'admin',
|
||||
'write_error_log' => 'fatal',
|
||||
'allow' => array(),
|
||||
),
|
||||
'seo' => array(
|
||||
|
|
|
|||
|
|
@ -22,11 +22,6 @@ class Debug
|
|||
protected static $_remote_requests = array();
|
||||
protected static $_slow_remote_requests = array();
|
||||
|
||||
/**
|
||||
* Also write to error log.
|
||||
*/
|
||||
public static $write_to_error_log = true;
|
||||
|
||||
/**
|
||||
* Get all entries.
|
||||
*
|
||||
|
|
@ -166,7 +161,7 @@ class Debug
|
|||
self::$_entries[] = $entry;
|
||||
|
||||
// Add the entry to the error log.
|
||||
if (self::$write_to_error_log && self::isEnabledForCurrentUser())
|
||||
if (config('debug.write_error_log') === 'all' && self::isEnabledForCurrentUser())
|
||||
{
|
||||
$log_entry = str_replace("\0", '', sprintf('Rhymix Debug: %s in %s on line %d',
|
||||
var_export($message, true), $entry->file, $entry->line));
|
||||
|
|
@ -215,7 +210,7 @@ class Debug
|
|||
);
|
||||
|
||||
// Add the entry to the error log.
|
||||
if (self::$write_to_error_log)
|
||||
if (config('debug.write_error_log') === 'all')
|
||||
{
|
||||
$log_entry = strtr(sprintf('PHP %s: %s in %s on line %d', $errinfo->type, $errstr, $errfile, intval($errline)), "\0\r\n\t\v\e\f", ' ');
|
||||
error_log($log_entry . \PHP_EOL . self::formatBacktrace($backtrace));
|
||||
|
|
@ -371,7 +366,10 @@ class Debug
|
|||
$log_entry = str_replace("\0", '', sprintf('%s #%d "%s" in %s on line %d',
|
||||
get_class($e), $e->getCode(), $e->getMessage(), $errfile, $e->getLine()));
|
||||
}
|
||||
error_log('PHP Exception: ' . $log_entry . \PHP_EOL . self::formatBacktrace($e->getTrace()));
|
||||
if (config('debug.write_error_log') !== 'none')
|
||||
{
|
||||
error_log('PHP Exception: ' . $log_entry . \PHP_EOL . self::formatBacktrace($e->getTrace()));
|
||||
}
|
||||
|
||||
// Display the error screen.
|
||||
self::displayErrorScreen($log_entry);
|
||||
|
|
@ -398,7 +396,10 @@ class Debug
|
|||
// Add the entry to the error log.
|
||||
$message = sprintf('%s in %s on line %d', $errinfo['message'], $errinfo['file'], intval($errinfo['line']));
|
||||
$log_entry = str_replace("\0", '', 'PHP ' . self::getErrorType($errinfo['type']) . ': ' . $message);
|
||||
error_log($log_entry);
|
||||
if (config('debug.write_error_log') !== 'none')
|
||||
{
|
||||
error_log($log_entry);
|
||||
}
|
||||
|
||||
// Display the error screen.
|
||||
self::displayErrorScreen($log_entry);
|
||||
|
|
|
|||
|
|
@ -737,6 +737,7 @@ class adminAdminController extends admin
|
|||
Rhymix\Framework\Config::set('debug.log_slow_remote_requests', max(0, floatval($vars->debug_log_slow_remote_requests)));
|
||||
Rhymix\Framework\Config::set('debug.display_type', strval($vars->debug_display_type) ?: 'comment');
|
||||
Rhymix\Framework\Config::set('debug.display_to', strval($vars->debug_display_to) ?: 'admin');
|
||||
Rhymix\Framework\Config::set('debug.write_error_log', strval($vars->debug_write_error_log) ?: 'fatal');
|
||||
|
||||
// Debug content
|
||||
$debug_content = array_values($vars->debug_display_content);
|
||||
|
|
|
|||
|
|
@ -559,6 +559,7 @@ class adminAdminView extends admin
|
|||
Context::set('debug_display_type', Rhymix\Framework\Config::get('debug.display_type'));
|
||||
Context::set('debug_display_content', Rhymix\Framework\Config::get('debug.display_content'));
|
||||
Context::set('debug_display_to', Rhymix\Framework\Config::get('debug.display_to'));
|
||||
Context::set('debug_write_error_log', Rhymix\Framework\Config::get('debug.write_error_log'));
|
||||
|
||||
// IP access control
|
||||
$allowed_ip = Rhymix\Framework\Config::get('debug.allow');
|
||||
|
|
|
|||
|
|
@ -159,6 +159,10 @@ $lang->debug_display_to_admin = 'Administrator only';
|
|||
$lang->debug_display_to_ip = 'Visitors from IP adresses listed below';
|
||||
$lang->debug_display_to_everyone = 'Everyone';
|
||||
$lang->debug_log_filename = 'Log filename';
|
||||
$lang->debug_write_error_log = 'Write to Error Log';
|
||||
$lang->debug_write_error_log_all = 'All errors';
|
||||
$lang->debug_write_error_log_fatal = 'Fatal errors only';
|
||||
$lang->debug_write_error_log_none = 'None';
|
||||
$lang->about_debug_log_filename = 'YYYYMMDD in the filename will be replaced with the current date.<br>It is recommended to split the log file by date to prevent it from getting too large.';
|
||||
$lang->msg_debug_log_filename_not_writable = 'Rhymix cannot write log files in the specified path.';
|
||||
$lang->debug_allowed_ip = 'Allowed IP addresses';
|
||||
|
|
|
|||
|
|
@ -154,6 +154,10 @@ $lang->debug_display_to_admin = '관리자에게만 표시';
|
|||
$lang->debug_display_to_ip = '아래 IP의 방문자에게만 표시';
|
||||
$lang->debug_display_to_everyone = '모두에게 표시';
|
||||
$lang->debug_log_filename = '디버그 정보 기록 파일';
|
||||
$lang->debug_write_error_log = '에러 로그에 기록';
|
||||
$lang->debug_write_error_log_all = '모든 에러를 기록';
|
||||
$lang->debug_write_error_log_fatal = '치명적인 에러만 기록';
|
||||
$lang->debug_write_error_log_none = '기록하지 않음';
|
||||
$lang->about_debug_log_filename = '파일명에 YYYYMMDD가 포함된 경우 날짜별로 파일을 분리하여 기록합니다.<br>파일을 분리하지 않으면 용량이 매우 커질 수 있으니 주의하십시오.';
|
||||
$lang->msg_debug_log_filename_not_writable = '지정한 경로에 로그 파일을 작성할 수 없습니다.';
|
||||
$lang->debug_allowed_ip = '디버그 허용 IP';
|
||||
|
|
|
|||
|
|
@ -84,6 +84,14 @@
|
|||
<textarea name="debug_allowed_ip" id="debug_allowed_ip" rows="4" cols="42" placeholder="{$remote_addr} ({$lang->local_ip_address})" style="margin-right:10px">{$debug_allowed_ip}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="debug_log_slow_widgets">{$lang->debug_write_error_log}</label>
|
||||
<div class="x_controls">
|
||||
<label for="debug_write_error_log_all" class="x_inline"><input type="radio" name="debug_write_error_log" id="debug_write_error_log_all" value="all" checked="checked"|cond="$debug_write_error_log=='all'" /> {$lang->debug_write_error_log_all}</label>
|
||||
<label for="debug_write_error_log_fatal" class="x_inline"><input type="radio" name="debug_write_error_log" id="debug_write_error_log_fatal" value="fatal" checked="checked"|cond="$debug_write_error_log=='fatal' || !$debug_write_error_log" /> {$lang->debug_write_error_log_fatal}</label>
|
||||
<label for="debug_write_error_log_none" class="x_inline"><input type="radio" name="debug_write_error_log" id="debug_write_error_log_none" value="none" checked="checked"|cond="$debug_write_error_log=='none'" /> {$lang->debug_write_error_log_none}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_clearfix btnArea">
|
||||
<div class="x_pull-right">
|
||||
<button type="submit" class="x_btn x_btn-primary">{$lang->cmd_save}</button>
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ class DebugTest extends \Codeception\TestCase\Test
|
|||
public function testDebugEntry()
|
||||
{
|
||||
$file = __FILE__;
|
||||
$line = __LINE__ + 2;
|
||||
Rhymix\Framework\Debug::$write_to_error_log = false;
|
||||
$line = __LINE__ + 1;
|
||||
Rhymix\Framework\Debug::addEntry('foobar entry');
|
||||
$entries = Rhymix\Framework\Debug::getEntries();
|
||||
$this->assertEquals(1, count($entries));
|
||||
|
|
@ -18,8 +17,7 @@ class DebugTest extends \Codeception\TestCase\Test
|
|||
public function testDebugError()
|
||||
{
|
||||
$file = __FILE__;
|
||||
$line = __LINE__ + 2;
|
||||
Rhymix\Framework\Debug::$write_to_error_log = false;
|
||||
$line = __LINE__ + 1;
|
||||
Rhymix\Framework\Debug::addError(~0, 'Rhymix', $file, $line, null);
|
||||
$errors = Rhymix\Framework\Debug::getErrors();
|
||||
$this->assertGreaterThanOrEqual(1, count($errors));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue