revert Log's dependency to SystemConfig to work during Installation
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
69592408c4
commit
0e6a317516
|
@ -39,7 +39,6 @@ use InterfaSys\LogNormalizer\Normalizer;
|
|||
|
||||
use OC\Log\ExceptionSerializer;
|
||||
use OCP\Log\IFileBased;
|
||||
use OCP\IConfig;
|
||||
use OCP\Log\IWriter;
|
||||
use OCP\ILogger;
|
||||
use OCP\Support\CrashReport\IRegistry;
|
||||
|
@ -59,7 +58,7 @@ class Log implements ILogger {
|
|||
/** @var IWriter */
|
||||
private $logger;
|
||||
|
||||
/** @var IConfig */
|
||||
/** @var SystemConfig */
|
||||
private $config;
|
||||
|
||||
/** @var boolean|null cache the result of the log condition check for the request */
|
||||
|
@ -73,14 +72,14 @@ class Log implements ILogger {
|
|||
|
||||
/**
|
||||
* @param IWriter $logger The logger that should be used
|
||||
* @param IConfig $config the system config object
|
||||
* @param SystemConfig $config the system config object
|
||||
* @param Normalizer|null $normalizer
|
||||
* @param IRegistry|null $registry
|
||||
*/
|
||||
public function __construct(IWriter $logger, IConfig $config = null, $normalizer = null, IRegistry $registry = null) {
|
||||
public function __construct(IWriter $logger, SystemConfig $config = null, $normalizer = null, IRegistry $registry = null) {
|
||||
// FIXME: Add this for backwards compatibility, should be fixed at some point probably
|
||||
if ($config === null) {
|
||||
$config = \OC::$server->getConfig();
|
||||
$config = \OC::$server->getSystemConfig();
|
||||
}
|
||||
|
||||
$this->config = $config;
|
||||
|
@ -258,7 +257,7 @@ class Log implements ILogger {
|
|||
}
|
||||
|
||||
if (isset($context['app'])) {
|
||||
$logCondition = $this->config->getSystemValue('log.condition', []);
|
||||
$logCondition = $this->config->getValue('log.condition', []);
|
||||
$app = $context['app'];
|
||||
|
||||
/**
|
||||
|
@ -272,7 +271,7 @@ class Log implements ILogger {
|
|||
}
|
||||
}
|
||||
|
||||
return min($this->config->getSystemValue('loglevel', ILogger::WARN), ILogger::FATAL);
|
||||
return min($this->config->getValue('loglevel', ILogger::WARN), ILogger::FATAL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
namespace OC\Log;
|
||||
|
||||
use OC\AllConfig;
|
||||
use OC\Log;
|
||||
use OCP\ILogger;
|
||||
use OCP\IServerContainer;
|
||||
|
@ -60,8 +61,14 @@ class LogFactory implements ILogFactory {
|
|||
}
|
||||
|
||||
public function getCustomLogger(string $path):ILogger {
|
||||
$systemConfig = null;
|
||||
$iconfig = $this->c->getConfig();
|
||||
if($iconfig instanceof AllConfig) {
|
||||
// Log is bound to SystemConfig, but fetches it from \OC::$server if not supplied
|
||||
$systemConfig = $iconfig->getSystemConfig();
|
||||
}
|
||||
$log = $this->buildLogFile($path);
|
||||
return new Log($log, $this->c->getConfig());
|
||||
return new Log($log, $systemConfig);
|
||||
}
|
||||
|
||||
protected function buildLogFile(string $logFile = ''):File {
|
||||
|
|
|
@ -550,10 +550,9 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
|
||||
$factory = new LogFactory($c);
|
||||
$logger = $factory->get($logType);
|
||||
$config = $this->getConfig();
|
||||
$registry = $c->query(\OCP\Support\CrashReport\IRegistry::class);
|
||||
|
||||
return new Log($logger, $config, null, $registry);
|
||||
return new Log($logger, $this->getSystemConfig(), null, $registry);
|
||||
});
|
||||
$this->registerAlias('Logger', \OCP\ILogger::class);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class LoggerTest extends TestCase implements IWriter {
|
|||
parent::setUp();
|
||||
|
||||
$this->logs = [];
|
||||
$this->config = $this->createMock(\OCP\IConfig::class);
|
||||
$this->config = $this->createMock(\OC\SystemConfig::class);
|
||||
$this->registry = $this->createMock(\OCP\Support\CrashReport\IRegistry::class);
|
||||
$this->logger = new Log($this, $this->config, null, $this->registry);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class LoggerTest extends TestCase implements IWriter {
|
|||
|
||||
public function testAppCondition() {
|
||||
$this->config->expects($this->any())
|
||||
->method('getSystemValue')
|
||||
->method('getValue')
|
||||
->will(($this->returnValueMap([
|
||||
['loglevel', ILogger::WARN, ILogger::WARN],
|
||||
['log.condition', [], ['apps' => ['files']]]
|
||||
|
|
Loading…
Reference in New Issue