Get rid of debug_level (#6298)

pull/6302/head
Aleksander Machniak 6 years ago
parent d0205f613d
commit 4b97f40af9

@ -66,6 +66,7 @@ CHANGELOG Roundcube Webmail
- Plugin API: Added 'show_bytes' hook (#5001)
- Add option to not indent quoted text on top-posting reply (#5105)
- Removed global $CONFIG variable
- Removed debug_level setting
- Support AUTHENTICATE LOGIN for IMAP connections (#5563)
- Support LDAP GSSAPI authentication (#5703)
- Localized timezone selector (#4983)

@ -76,7 +76,9 @@ and configure your installation to be not surprised by default behaviour.
Roundcube writes internal errors to the 'errors' log file located in the logs
directory which can be configured in config/config.inc.php. If you want ordinary
PHP errors to be logged there as well, set error_log php.ini or .htaccess file.
PHP errors to be logged there as well, set error_log in php.ini or .htaccess file.
Roundcube forces display_errors=Off and log_errors=On.
By default the session cookie settings of PHP are not modified by Roundcube.
However if you want to limit the session cookies to the directory where

@ -63,9 +63,6 @@ $config['db_max_allowed_packet'] = null;
// LOGGING/DEBUGGING
// ----------------------------------
// system error reporting, sum of: 1 = log; 4 = show
$config['debug_level'] = 1;
// log driver: 'syslog', 'stdout' or 'file'.
$config['log_driver'] = 'file';

@ -11,7 +11,6 @@ $RCI->bool_config_props = array(
'auto_create_user' => 1,
'smtp_log' => 1,
'prefer_html' => 1,
'debug_level' => 1,
);
// allow the current user to get to the next step
@ -196,21 +195,6 @@ echo $input_ilevel->show($RCI->getprop('identities_level'), 0);
<legend>Logging & Debugging</legend>
<dl class="loggingblock">
<dt class="propname">debug_level</dt>
<dd>
<?php
$value = $RCI->getprop('debug_level');
$check_debug = new html_checkbox(array('name' => '_debug_level[]'));
echo $check_debug->show(($value & 1) ? 1 : 0 , array('value' => 1, 'id' => 'cfgdebug1'));
echo '<label for="cfgdebug1">Log errors</label><br />';
echo $check_debug->show(($value & 4) ? 4 : 0, array('value' => 4, 'id' => 'cfgdebug4'));
echo '<label for="cfgdebug4">Print errors (to the browser)</label><br />';
?>
</dd>
<dt class="propname">log_driver</dt>
<dd>
<?php

@ -206,16 +206,7 @@ class rcmail_install
}
// convert some form data
if ($prop == 'debug_level' && !$is_default) {
if (is_array($value)) {
$val = 0;
foreach ($value as $dbgval) {
$val += intval($dbgval);
}
$value = $val;
}
}
else if ($prop == 'db_dsnw' && !empty($_POST['_dbtype'])) {
if ($prop == 'db_dsnw' && !empty($_POST['_dbtype'])) {
if ($_POST['_dbtype'] == 'sqlite') {
$value = sprintf('%s://%s?mode=0646', $_POST['_dbtype'],
$_POST['_dbname']{0} == '/' ? '/' . $_POST['_dbname'] : $_POST['_dbname']);

@ -1352,7 +1352,7 @@ class rcube
}
/**
* Report error according to configured debug_level
* Log an error
*
* @param array $arg_arr Named parameters
* @see self::raise_error()
@ -1360,58 +1360,31 @@ class rcube
public static function log_bug($arg_arr)
{
$program = strtoupper($arg_arr['type'] ?: 'php');
$level = self::get_instance()->config->get('debug_level');
// disable errors for ajax requests, write to log instead (#1487831)
if (($level & 4) && !empty($_REQUEST['_remote'])) {
$level = ($level ^ 4) | 1;
}
// write error to local log file
if (($level & 1) || !empty($arg_arr['fatal'])) {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
foreach (array('_task', '_action') as $arg) {
if ($_POST[$arg] && !$_GET[$arg]) {
$post_query[$arg] = $_POST[$arg];
}
}
if (!empty($post_query)) {
$post_query = (strpos($_SERVER['REQUEST_URI'], '?') != false ? '&' : '?')
. http_build_query($post_query, '', '&');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
foreach (array('_task', '_action') as $arg) {
if ($_POST[$arg] && !$_GET[$arg]) {
$post_query[$arg] = $_POST[$arg];
}
}
$log_entry = sprintf("%s Error: %s%s (%s %s)",
$program,
$arg_arr['message'],
$arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '',
$_SERVER['REQUEST_METHOD'],
$_SERVER['REQUEST_URI'] . $post_query);
if (!self::write_log('errors', $log_entry)) {
// send error to PHPs error handler if write_log didn't succeed
trigger_error($arg_arr['message'], E_USER_WARNING);
if (!empty($post_query)) {
$post_query = (strpos($_SERVER['REQUEST_URI'], '?') != false ? '&' : '?')
. http_build_query($post_query, '', '&');
}
}
// report the bug to the global bug reporting system
if ($level & 2) {
// TODO: Send error via HTTP
}
// show error if debug_mode is on
if ($level & 4) {
print "<b>$program Error";
if (!empty($arg_arr['file']) && !empty($arg_arr['line'])) {
print " in $arg_arr[file] ($arg_arr[line])";
}
$log_entry = sprintf("%s Error: %s%s (%s %s)",
$program,
$arg_arr['message'],
$arg_arr['file'] ? sprintf(' in %s on line %d', $arg_arr['file'], $arg_arr['line']) : '',
$_SERVER['REQUEST_METHOD'],
$_SERVER['REQUEST_URI'] . $post_query);
print ':</b>&nbsp;';
print nl2br($arg_arr['message']);
print '<br />';
flush();
if (!self::write_log('errors', $log_entry)) {
// send error to PHPs error handler if write_log didn't succeed
trigger_error($arg_arr['message'], E_USER_WARNING);
}
}

@ -245,20 +245,14 @@ class rcube_config
}
// set PHP error logging according to config
if ($this->prop['debug_level'] & 1) {
$error_log = $this->prop['log_driver'];
if ($error_log != 'syslog') {
$error_log = $this->prop['log_dir'] . '/errors';
$error_log .= isset($this->prop['log_file_ext']) ? $this->prop['log_file_ext'] : '.log';
}
$error_log = $this->prop['log_driver'];
if ($error_log != 'syslog') {
$error_log = $this->prop['log_dir'] . '/errors';
$error_log .= isset($this->prop['log_file_ext']) ? $this->prop['log_file_ext'] : '.log';
ini_set('error_log', $error_log);
ini_set('log_errors', 1);
}
// enable display_errors in 'show' level, but not for ajax requests
ini_set('display_errors', intval(empty($_REQUEST['_remote']) && ($this->prop['debug_level'] & 4)));
// remove deprecated properties
unset($this->prop['dst_active']);
}

@ -96,14 +96,7 @@ else if ($ERROR_CODE == 603) {
// system error
else {
$__error_title = "SERVICE CURRENTLY NOT AVAILABLE!";
$__error_text = "Please contact your server-administrator.";
if (($rcmail->config->get('debug_level') & 4) && $ERROR_MESSAGE) {
$__error_text = $ERROR_MESSAGE;
}
else {
$__error_text = sprintf('Error No. [%s]', $ERROR_CODE);
}
$__error_text = sprintf('Error No. [%s]', $ERROR_CODE);
}
// inform plugins

Loading…
Cancel
Save