3 * @copyright Copyright (C) 2020, Friendica
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\Util\Logger;
24 use Friendica\Core\System;
25 use Friendica\Util\Profiler;
26 use Psr\Log\LoggerInterface;
29 * This Logger adds additional profiling data in case profiling is enabled.
30 * It uses a predefined logger.
32 class ProfilerLogger implements LoggerInterface
35 * The Logger of the current call
36 * @var LoggerInterface
41 * The Profiler for the current call
47 * ProfilerLogger constructor.
48 * @param LoggerInterface $logger The Logger of the current call
49 * @param Profiler $profiler The profiler of the current call
51 public function __construct(LoggerInterface $logger, Profiler $profiler)
53 $this->logger = $logger;
54 $this->profiler = $profiler;
60 public function emergency($message, array $context = array())
62 $stamp1 = microtime(true);
63 $this->logger->emergency($message, $context);
64 $this->profiler->saveTimestamp($stamp1, 'file');
70 public function alert($message, array $context = array())
72 $stamp1 = microtime(true);
73 $this->logger->alert($message, $context);
74 $this->profiler->saveTimestamp($stamp1, 'file');
80 public function critical($message, array $context = array())
82 $stamp1 = microtime(true);
83 $this->logger->critical($message, $context);
84 $this->profiler->saveTimestamp($stamp1, 'file');
90 public function error($message, array $context = array())
92 $stamp1 = microtime(true);
93 $this->logger->error($message, $context);
94 $this->profiler->saveTimestamp($stamp1, 'file');
100 public function warning($message, array $context = array())
102 $stamp1 = microtime(true);
103 $this->logger->warning($message, $context);
104 $this->profiler->saveTimestamp($stamp1, 'file');
110 public function notice($message, array $context = array())
112 $stamp1 = microtime(true);
113 $this->logger->notice($message, $context);
114 $this->profiler->saveTimestamp($stamp1, 'file');
120 public function info($message, array $context = array())
122 $stamp1 = microtime(true);
123 $this->logger->info($message, $context);
124 $this->profiler->saveTimestamp($stamp1, 'file');
130 public function debug($message, array $context = array())
132 $stamp1 = microtime(true);
133 $this->logger->debug($message, $context);
134 $this->profiler->saveTimestamp($stamp1, 'file');
140 public function log($level, $message, array $context = array())
142 $stamp1 = microtime(true);
143 $this->logger->log($level, $message, $context);
144 $this->profiler->saveTimestamp($stamp1, 'file');