/**
* @copyright Copyright (C) 2010-2023, the Friendica project
*
- * @license GNU AGPL version 3 or any later version
+ * @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
namespace Friendica\Core\Logger\Factory;
use Friendica\Core\Config\Capability\IManageConfigValues;
-use Friendica\Core\Logger\Capabilities\LogChannel;
+use Friendica\Core\Logger\Capability\LogChannel;
use Friendica\Core\Logger\Exception\LoggerArgumentException;
use Friendica\Core\Logger\Exception\LoggerException;
+use Friendica\Core\Logger\Exception\LogLevelException;
use Friendica\Core\Logger\Type\StreamLogger as StreamLoggerClass;
use Friendica\Core\Logger\Util\FileSystem;
use Psr\Log\LoggerInterface;
-use Psr\Log\LogLevel;
use Psr\Log\NullLogger;
/**
$fileSystem = new FileSystem();
$logfile = $logfile ?? $config->get('system', 'logfile');
- if ((@file_exists($logfile) && !@is_writable($logfile)) && !@is_writable(basename($logfile))) {
+ if (!@file_exists($logfile) || !@is_writable($logfile)) {
throw new LoggerArgumentException(sprintf('%s is not a valid logfile', $logfile));
}
if (array_key_exists($loglevel, StreamLoggerClass::levelToInt)) {
$loglevel = StreamLoggerClass::levelToInt[$loglevel];
} else {
- $loglevel = StreamLoggerClass::levelToInt[LogLevel::NOTICE];
+ throw new LogLevelException(sprintf('The level "%s" is not valid.', $loglevel));
}
$stream = $fileSystem->createStream($logfile);