3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Core\Logger\Type;
24 use Friendica\Util\Profiler;
25 use Psr\Log\LoggerInterface;
28 * This Logger adds additional profiling data in case profiling is enabled.
29 * It uses a predefined logger.
31 class ProfilerLogger implements LoggerInterface
34 * The Logger of the current call
35 * @var LoggerInterface
40 * The Profiler for the current call
46 * ProfilerLogger constructor.
47 * @param LoggerInterface $logger The Logger of the current call
48 * @param Profiler $profiler The profiler of the current call
50 public function __construct(LoggerInterface $logger, Profiler $profiler)
52 $this->logger = $logger;
53 $this->profiler = $profiler;
59 public function emergency($message, array $context = [])
61 $this->profiler->startRecording('file');
62 $this->logger->emergency($message, $context);
63 $this->profiler->stopRecording();
69 public function alert($message, array $context = [])
71 $this->profiler->startRecording('file');
72 $this->logger->alert($message, $context);
73 $this->profiler->stopRecording();
79 public function critical($message, array $context = [])
81 $this->profiler->startRecording('file');
82 $this->logger->critical($message, $context);
83 $this->profiler->stopRecording();
89 public function error($message, array $context = [])
91 $this->profiler->startRecording('file');
92 $this->logger->error($message, $context);
93 $this->profiler->stopRecording();
99 public function warning($message, array $context = [])
101 $this->profiler->startRecording('file');
102 $this->logger->warning($message, $context);
103 $this->profiler->stopRecording();
109 public function notice($message, array $context = [])
111 $this->profiler->startRecording('file');
112 $this->logger->notice($message, $context);
113 $this->profiler->stopRecording();
119 public function info($message, array $context = [])
121 $this->profiler->startRecording('file');
122 $this->logger->info($message, $context);
123 $this->profiler->stopRecording();
129 public function debug($message, array $context = [])
131 $this->profiler->startRecording('file');
132 $this->logger->debug($message, $context);
133 $this->profiler->stopRecording();
139 public function log($level, $message, array $context = [])
141 $this->profiler->startRecording('file');
142 $this->logger->log($level, $message, $context);
143 $this->profiler->stopRecording();