alltube/classes/Factory/LoggerFactory.php
Pierre Rudloff f475fa2a47
Lint
2023-03-03 00:18:00 +01:00

40 lines
978 B
PHP

<?php
namespace Alltube\Factory;
use Consolidation\Log\Logger;
use Consolidation\Log\LoggerManager;
use Consolidation\Log\LogOutputStyler;
use Slim\Container;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Class LoggerFactory
* @package Alltube
*/
class LoggerFactory
{
/**
* @param Container $container
* @return LoggerManager
*/
public static function create(Container $container): LoggerManager
{
$config = $container->get('config');
if ($config->debug) {
$verbosity = OutputInterface::VERBOSITY_DEBUG;
} else {
$verbosity = OutputInterface::VERBOSITY_NORMAL;
}
$loggerManager = new LoggerManager();
$logger = new Logger(new ConsoleOutput($verbosity));
$logger->setLogOutputStyler(new LogOutputStyler());
$loggerManager->add('default', $logger);
return $loggerManager;
}
}