alltube/classes/Factory/LoggerFactory.php

36 lines
766 B
PHP
Raw Normal View History

<?php
2020-10-20 21:29:50 +00:00
namespace Alltube\Factory;
use Consolidation\Log\Logger;
use Consolidation\Log\LogOutputStyler;
use Slim\Container;
use Symfony\Component\Console\Output\ConsoleOutput;
/**
* Class LoggerFactory
* @package Alltube
*/
class LoggerFactory
{
/**
* @param Container $container
* @return Logger
*/
2020-12-17 21:43:05 +00:00
public static function create(Container $container): Logger
{
$config = $container->get('config');
if ($config->debug) {
$verbosity = ConsoleOutput::VERBOSITY_DEBUG;
} else {
$verbosity = ConsoleOutput::VERBOSITY_NORMAL;
}
$logger = new Logger(new ConsoleOutput($verbosity));
$logger->setLogOutputStyler(new LogOutputStyler());
return $logger;
}
}