Make Log-Level configurable (#131)
This commit is contained in:
@@ -21,7 +21,9 @@ Version 2.0-beta3 ()
|
||||
option, but can be selected as a new frontend theme, while
|
||||
using 2k11 (=default) in the backend.
|
||||
|
||||
* Include klogger, call it as $serendipity['logger']->debug/error
|
||||
* Include klogger, call it as $serendipity['logger']->debug/error.
|
||||
The log-level is by default determined automatically, but can also
|
||||
be set in the general configuration.
|
||||
|
||||
* Fixed missing s9ymdb ID
|
||||
|
||||
|
@@ -404,6 +404,12 @@
|
||||
'type' => 'list',
|
||||
'default' => array('stable' => 'stable', 'beta' => 'beta', 'false' => NO ), # i18n
|
||||
'permission' => 'blogConfiguration'),
|
||||
array('var' => 'logLevel',
|
||||
'title' => LOG_LEVEL,
|
||||
'description' => LOG_LEVEL_DESC,
|
||||
'type' => 'list',
|
||||
'default' => array('Automatic' => AUTOMATIC, 'error' => ERROR, 'debug' => DEBUG), # i18n
|
||||
'permission' => 'blogConfiguration'),
|
||||
));
|
||||
|
||||
$res['display'] =
|
||||
|
@@ -2,4 +2,9 @@
|
||||
@define('BACKEND', 'Backend');
|
||||
|
||||
@define('MEDIA_UPLOAD_RESIZE', 'Resize before Upload');
|
||||
@define('MEDIA_UPLOAD_RESIZE_DESC', 'Resize images to the given max-values before the upload using Javascript. This will also change the uploader to use Ajax and thus remove the Property-Button');
|
||||
@define('MEDIA_UPLOAD_RESIZE_DESC', 'Resize images before the upload using Javascript. This will also change the uploader to use Ajax and thus remove the Property-Button');
|
||||
|
||||
@define('LOG_LEVEL', 'Log Level');
|
||||
@define('LOG_LEVEL_DESC', 'The logger can react to the s9y status and debug in RC-version and smaller, but only log errors in produciton. Or the level can be set manually.');
|
||||
@define('DEBUG', 'Debug');
|
||||
@define('AUTOMATIC', 'Automatisch');
|
@@ -7,7 +7,6 @@ if (defined('S9Y_FRAMEWORK')) {
|
||||
}
|
||||
|
||||
@define('S9Y_FRAMEWORK', true);
|
||||
|
||||
if (!headers_sent() && php_sapi_name() !== 'cli') {
|
||||
// Only set the session name, if no session has yet been issued.
|
||||
if (session_id() == '') {
|
||||
@@ -47,9 +46,10 @@ if (defined('USE_MEMSNAP')) {
|
||||
// The version string
|
||||
$serendipity['version'] = '2.0-beta2';
|
||||
|
||||
|
||||
// Setting this to 'false' will enable debugging output. All alpha/beta/cvs snapshot versions will emit debug information by default. To increase the debug level (to enable Smarty debugging), set this flag to 'debug'.
|
||||
if (!isset($serendipity['production'])) {
|
||||
$serendipity['production'] = (preg_match('@\-(alpha|beta|cvs|rc)@', $serendipity['version']) ? false : true);
|
||||
$serendipity['production'] = ! preg_match('@\-(alpha|beta|cvs|rc).*@', $serendipity['version']);
|
||||
}
|
||||
|
||||
// Set error reporting
|
||||
@@ -262,13 +262,8 @@ include($local_config);
|
||||
|
||||
if ($serendipity['production'] === 'debug') {
|
||||
error_reporting(E_ALL &~E_NOTICE | E_STRICT);
|
||||
$serendipity['log_level'] = Psr\Log\LogLevel::DEBUG;
|
||||
} else {
|
||||
$serendipity['log_level'] = Psr\Log\LogLevel::ERROR;
|
||||
}
|
||||
|
||||
$serendipity['logger'] = new Katzgrau\KLogger\Logger($serendipity['serendipityPath'] . '/templates_c/logs', $serendipity['log_level']);
|
||||
|
||||
//[internal callback function]: errorToExceptionHandler()
|
||||
if(is_callable($serendipity['errorhandler'], false, $callable_name)) {
|
||||
// set serendipity global error to exeption handler
|
||||
@@ -291,7 +286,6 @@ include(S9Y_INCLUDE_PATH . 'include/functions.inc.php');
|
||||
if (serendipity_FUNCTIONS_LOADED !== true) {
|
||||
$serendipity['lang'] = 'en';
|
||||
include(S9Y_INCLUDE_PATH . 'include/lang.inc.php');
|
||||
$serendipity['logger']->critical(sprintf(INCLUDE_ERROR . '<br />' . FILE_CREATE_YOURSELF, 'include/functions.inc.php'));
|
||||
serendipity_die(sprintf(INCLUDE_ERROR . '<br />' . FILE_CREATE_YOURSELF, 'include/functions.inc.php'));
|
||||
}
|
||||
|
||||
@@ -316,6 +310,23 @@ if (defined('USE_MEMSNAP')) {
|
||||
serendipity_load_configuration();
|
||||
$serendipity['lang'] = serendipity_getSessionLanguage();
|
||||
|
||||
if (! isset($serendipity['logLevel']) || $serendipity['logLevel'] === 'Automatic') {
|
||||
if ($serendipity['production'] != true) {
|
||||
$log_level = Psr\Log\LogLevel::DEBUG;
|
||||
} else {
|
||||
$log_level = Psr\Log\LogLevel::ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if ($serendipity['logLevel'] == 'error') {
|
||||
$log_level = Psr\Log\LogLevel::ERROR;
|
||||
}
|
||||
if ($serendipity['logLevel'] == 'debug') {
|
||||
$log_level = Psr\Log\LogLevel::DEBUG;
|
||||
}
|
||||
|
||||
$serendipity['logger'] = new Katzgrau\KLogger\Logger($serendipity['serendipityPath'] . '/templates_c/logs', $log_level);
|
||||
|
||||
if ( (isset($serendipity['autodetect_baseURL']) && serendipity_db_bool($serendipity['autodetect_baseURL'])) ||
|
||||
(isset($serendipity['embed']) && serendipity_db_bool($serendipity['embed'])) ) {
|
||||
$serendipity['baseURL'] = 'http' . (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . (!strstr($_SERVER['HTTP_HOST'], ':') && !empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != '80' && $_SERVER['SERVER_PORT'] != '443' ? ':' . $_SERVER['SERVER_PORT'] : '') . $serendipity['serendipityHTTPPath'];
|
||||
|
Reference in New Issue
Block a user