mirror of
https://github.com/friendica/friendica
synced 2025-04-27 04:30:11 +00:00
Always return NullLogger if debug is disabled
This commit is contained in:
parent
4a8533aa11
commit
f65a838594
2 changed files with 35 additions and 5 deletions
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Friendica\Core\Logger\Factory;
|
||||
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
|
@ -17,14 +18,31 @@ use Psr\Log\NullLogger;
|
|||
*/
|
||||
final class LoggerFactory
|
||||
{
|
||||
private bool $debug;
|
||||
|
||||
private LoggerInterface $logger;
|
||||
|
||||
public function __construct(IManageConfigValues $config)
|
||||
{
|
||||
$this->debug = (bool) $config->get('system', 'debugging') ?? false;
|
||||
}
|
||||
|
||||
public function create(): LoggerInterface
|
||||
{
|
||||
if (! isset($this->logger)) {
|
||||
$this->logger = new NullLogger();
|
||||
$this->logger = $this->createLogger();
|
||||
}
|
||||
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
private function createLogger(): LoggerInterface
|
||||
{
|
||||
// Always return NullLogger if debug is disabled
|
||||
if ($this->debug === false) {
|
||||
return new NullLogger();
|
||||
}
|
||||
|
||||
return new NullLogger();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue