--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2010-2022, the Friendica project
+ *
+ * @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
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Core\Logger\Capabilities;
+use Friendica\Core\Logger\Factory\Logger;
+use Friendica\Util\Profiler;
+
+interface IHaveCallIntrospections
+{
+ /**
+ * A list of classes, which shouldn't get logged
+ *
+ * @var string[]
+ */
+ public const IGNORE_CLASS_LIST = [
+ Logger::class,
+ Profiler::class,
+ 'Friendica\\Core\\Logger\\Type',
+ ];
+
+ /**
+ * Adds new classes to get skipped
+ *
+ * @param array $classNames
+ */
+ public function addClasses(array $classNames): void;
+
+ /**
+ * Returns the introspection record of the current call
+ *
+ * @return array
+ */
+ public function getRecord(): array;
+}
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core;
+use Friendica\Core\Logger\Capabilities\IHaveCallIntrospections;
use Friendica\Core\Logger\Exception\LogLevelException;
use Friendica\Database\Database;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Util\FileSystem;
-use Friendica\Core\Logger\Util\Introspection;
use Friendica\Core\Logger\Type\ProfilerLogger;
use Friendica\Core\Logger\Type\StreamLogger;
use Friendica\Core\Logger\Type\SyslogLogger;
{
const DEV_CHANNEL = 'dev';
- /**
- * A list of classes, which shouldn't get logged
- *
- * @var string[]
- */
- private static $ignoreClassList = [
- Core\Logger::class,
- Profiler::class,
- 'Friendica\\Core\\Logger\\Type',
- ];
-
/** @var string The log-channel (app, worker, ...) */
private $channel;
*
* @return LoggerInterface The PSR-3 compliant logger instance
*/
- public function create(Database $database, IManageConfigValues $config, Profiler $profiler, FileSystem $fileSystem, ?string $minLevel = null): LoggerInterface
+ public function create(Database $database, IManageConfigValues $config, Profiler $profiler, FileSystem $fileSystem, IHaveCallIntrospections $introspection, ?string $minLevel = null): LoggerInterface
{
if (empty($config->get('system', 'debugging', false))) {
$logger = new NullLogger();
return $logger;
}
- $introspection = new Introspection(self::$ignoreClassList);
$minLevel = $minLevel ?? $config->get('system', 'loglevel');
$loglevel = self::mapLegacyConfigDebugLevel((string)$minLevel);
$logger = new SyslogLogger($this->channel, $introspection, $loglevel, $config->get('system', 'syslog_flags', SyslogLogger::DEFAULT_FLAGS), $config->get('system', 'syslog_facility', SyslogLogger::DEFAULT_FACILITY));
} catch (LogLevelException $exception) {
// If there's a wrong config value for loglevel, try again with standard
- $logger = $this->create($database, $config, $profiler, $fileSystem, LogLevel::NOTICE);
+ $logger = $this->create($database, $config, $profiler, $fileSystem, $introspection, LogLevel::NOTICE);
$logger->warning('Invalid loglevel set in config.', ['loglevel' => $loglevel]);
} catch (\Throwable $e) {
// No logger ...
$logger = new StreamLogger($this->channel, $stream, $introspection, $fileSystem, $loglevel);
} catch (LogLevelException $exception) {
// If there's a wrong config value for loglevel, try again with standard
- $logger = $this->create($database, $config, $profiler, $fileSystem, LogLevel::NOTICE);
+ $logger = $this->create($database, $config, $profiler, $fileSystem, $introspection, LogLevel::NOTICE);
$logger->warning('Invalid loglevel set in config.', ['loglevel' => $loglevel]);
} catch (\Throwable $t) {
// No logger ...
$logger = new SyslogLogger($this->channel, $introspection, $loglevel);
} catch (LogLevelException $exception) {
// If there's a wrong config value for loglevel, try again with standard
- $logger = $this->create($database, $config, $profiler, $fileSystem, LogLevel::NOTICE);
+ $logger = $this->create($database, $config, $profiler, $fileSystem, $introspection, LogLevel::NOTICE);
$logger->warning('Invalid loglevel set in config.', ['loglevel' => $loglevel]);
} catch (\Throwable $e) {
// No logger ...
* @return LoggerInterface The PSR-3 compliant logger instance
* @throws \Exception
*/
- public static function createDev(IManageConfigValues $config, Profiler $profiler, FileSystem $fileSystem)
+ public static function createDev(IManageConfigValues $config, Profiler $profiler, FileSystem $fileSystem, IHaveCallIntrospections $introspection)
{
$debugging = $config->get('system', 'debugging');
$stream = $config->get('system', 'dlogfile');
return new NullLogger();
}
- $introspection = new Introspection(self::$ignoreClassList);
-
$name = $config->get('system', 'logger_config', 'stream');
switch ($name) {