mirror of
https://github.com/friendica/friendica
synced 2024-12-23 01:21:27 +01:00
Merge pull request #7191 from nupplaphil/bug/logfile_permission
Fixing logfile permission denied exceptions
This commit is contained in:
commit
e99e8096bf
3 changed files with 47 additions and 13 deletions
|
@ -26,6 +26,7 @@ class LoggerFactory
|
|||
{
|
||||
/**
|
||||
* A list of classes, which shouldn't get logged
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $ignoreClassList = [
|
||||
|
@ -71,7 +72,10 @@ class LoggerFactory
|
|||
|
||||
$stream = $config->get('system', 'logfile');
|
||||
|
||||
// just add a stream in case it's either writable or not file
|
||||
if (!is_file($stream) || is_writable($stream)) {
|
||||
static::addStreamHandler($logger, $stream, $loglevel);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'syslog':
|
||||
|
@ -81,7 +85,12 @@ class LoggerFactory
|
|||
case 'stream':
|
||||
default:
|
||||
$stream = $config->get('system', 'logfile');
|
||||
// just add a stream in case it's either writable or not file
|
||||
if (!is_file($stream) || is_writable($stream)) {
|
||||
$logger = new StreamLogger($channel, $stream, $introspection, $loglevel);
|
||||
} else {
|
||||
$logger = new VoidLogger();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -120,7 +129,8 @@ class LoggerFactory
|
|||
$stream = $config->get('system', 'dlogfile');
|
||||
$developerIp = $config->get('system', 'dlogip');
|
||||
|
||||
if (!isset($developerIp) || !$debugging) {
|
||||
if ((!isset($developerIp) || !$debugging) &&
|
||||
(!is_file($stream) || is_writable($stream))) {
|
||||
$logger = new VoidLogger();
|
||||
Logger::setDevLogger($logger);
|
||||
return $logger;
|
||||
|
@ -172,6 +182,7 @@ class LoggerFactory
|
|||
|
||||
/**
|
||||
* Mapping a legacy level to the PSR-3 compliant levels
|
||||
*
|
||||
* @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#5-psrlogloglevel
|
||||
*
|
||||
* @param string $level the level to be mapped
|
||||
|
|
|
@ -22,6 +22,12 @@ class Settings extends BaseAdminModule
|
|||
$debugging = !empty($_POST['debugging']);
|
||||
$loglevel = defaults($_POST, 'loglevel', LogLevel::ERROR);
|
||||
|
||||
if (is_file($logfile) &&
|
||||
!is_writeable($logfile)) {
|
||||
notice(L10n::t('The logfile \'%s\' is not writable. No logging possible', $logfile));
|
||||
return;
|
||||
}
|
||||
|
||||
Config::set('system', 'logfile', $logfile);
|
||||
Config::set('system', 'debugging', $debugging);
|
||||
Config::set('system', 'loglevel', $loglevel);
|
||||
|
|
|
@ -74,6 +74,23 @@ class Summary extends BaseAdminModule
|
|||
$well_known, $well_known, $a->getBaseURL() . '/help/Install');
|
||||
}
|
||||
|
||||
// Check logfile permission
|
||||
if (Config::get('system', 'debugging')) {
|
||||
$stream = Config::get('system', 'logfile');
|
||||
|
||||
if (is_file($stream) &&
|
||||
!is_writeable($stream)) {
|
||||
$warningtext[] = L10n::t('The logfile \'%s\' is not writable. No logging possible', $stream);
|
||||
}
|
||||
|
||||
$stream = Config::get('system', 'dlogfile');
|
||||
|
||||
if (is_file($stream) &&
|
||||
!is_writeable($stream)) {
|
||||
$warningtext[] = L10n::t('The logfile \'%s\' is not writable. No logging possible', $stream);
|
||||
}
|
||||
}
|
||||
|
||||
// check legacy basepath settings
|
||||
$configLoader = new ConfigFileLoader($a->getBasePath(), $a->getMode());
|
||||
$configCache = new Config\Cache\ConfigCache();
|
||||
|
|
Loading…
Reference in a new issue