{
/**
* A list of classes, which shouldn't get logged
+ *
* @var array
*/
private static $ignoreClassList = [
/**
* Creates a new PSR-3 compliant logger instances
*
- * @param string $channel The channel of the logger instance
- * @param Configuration $config The config
+ * @param string $channel The channel of the logger instance
+ * @param Configuration $config The config
* @param Profiler $profiler The profiler of the app
*
* @return LoggerInterface The PSR-3 compliant logger instance
}
$introspection = new Introspection(self::$ignoreClassList);
- $level = $config->get('system', 'loglevel');
- $loglevel = self::mapLegacyConfigDebugLevel((string)$level);
+ $level = $config->get('system', 'loglevel');
+ $loglevel = self::mapLegacyConfigDebugLevel((string)$level);
switch ($config->get('system', 'logger_config', 'stream')) {
case 'monolog':
$stream = $config->get('system', 'logfile');
- static::addStreamHandler($logger, $stream, $loglevel);
+ // 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':
case 'stream':
default:
$stream = $config->get('system', 'logfile');
- $logger = new StreamLogger($channel, $stream, $introspection, $loglevel);
+ // 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;
}
*
* It should never get filled during normal usage of Friendica
*
- * @param string $channel The channel of the logger instance
- * @param Configuration $config The config
+ * @param string $channel The channel of the logger instance
+ * @param Configuration $config The config
* @param Profiler $profiler The profiler of the app
*
* @return LoggerInterface The PSR-3 compliant logger instance
$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;
break;
case 'syslog':
- $logger = new SyslogLogger($channel, $introspection, LogLevel::DEBUG);
+ $logger = new SyslogLogger($channel, $introspection, LogLevel::DEBUG);
break;
case 'stream':
/**
* 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
/**
* Adding a handler to a given logger instance
*
- * @param LoggerInterface $logger The logger instance
- * @param mixed $stream The stream which handles the logger output
- * @param string $level The level, for which this handler at least should handle logging
+ * @param LoggerInterface $logger The logger instance
+ * @param mixed $stream The stream which handles the logger output
+ * @param string $level The level, for which this handler at least should handle logging
*
* @return void
*
$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();