namespace Friendica\Core\Logger\Factory;
use Friendica\Core\Config\Capability\IManageConfigValues;
-use Friendica\Core\Hooks\Capabilities\ICanCreateInstances;
-use Friendica\Core\Logger\Capabilities\LogChannel;
+use Friendica\Core\Hooks\Capability\ICanCreateInstances;
+use Friendica\Core\Logger\Capability\LogChannel;
+use Friendica\Core\Logger\Type\ProfilerLogger as ProfilerLoggerClass;
+use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Throwable;
$this->channel = $channel;
}
- public function create(ICanCreateInstances $createInstances, IManageConfigValues $config): LoggerInterface
+ public function create(ICanCreateInstances $instanceCreator, IManageConfigValues $config, Profiler $profiler): LoggerInterface
{
if (empty($config->get('system', 'debugging') ?? false)) {
return new NullLogger();
$name = $config->get('system', 'logger_config') ?? '';
try {
- return $createInstances->createWithName(LoggerInterface::class, $name, [$this->channel]);
+ /** @var LoggerInterface $logger */
+ $logger = $instanceCreator->create(LoggerInterface::class, $name, [$this->channel]);
+ if ($config->get('system', 'profiling') ?? false) {
+ return new ProfilerLoggerClass($logger, $profiler);
+ } else {
+ return $logger;
+ }
} catch (Throwable $e) {
// No logger ...
return new NullLogger();