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