Commit 314ed89a authored by Jon Pugh's avatar Jon Pugh

Adding logger to Application by passing input and output.

parent 9dfc6bfb
......@@ -54,7 +54,7 @@ if ($debug){
}
try {
$application = new Application();
$application = new Application($input, $output);
$application->run();
}
catch (\Exception $e) {
......
......@@ -9,11 +9,13 @@ use Aegir\Provision\Command\StatusCommand;
use Aegir\Provision\Command\VerifyCommand;
use Aegir\Provision\Console\Config;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Symfony\Component\Console\Command\HelpCommand;
use Symfony\Component\Console\Command\ListCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Application as BaseApplication;
......@@ -50,10 +52,26 @@ class Application extends BaseApplication
* @var string
*/
const DEFAULT_TIMEZONE = 'America/New_York';
public function __construct()
/**
* @var LoggerInterface
*/
public $logger;
/**
* Application constructor.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @throws \Exception
*/
public function __construct(InputInterface $input, OutputInterface $output)
{
$this->logger = new ConsoleLogger($output,
[LogLevel::INFO => OutputInterface::VERBOSITY_NORMAL]
);
// If no timezone is set, set Default.
if (empty(ini_get('date.timezone'))) {
date_default_timezone_set($this::DEFAULT_TIMEZONE);
......
......@@ -71,9 +71,6 @@ abstract class Command extends BaseCommand
// Load context from context_name argument.
$this->context_name = $this->input->getArgument('context_name');
$this->context = $this->getApplication()->getContext($this->context_name);
$this->context->logger = new ConsoleLogger($output,
[LogLevel::INFO => OutputInterface::VERBOSITY_NORMAL]
);
}
catch (\Exception $e) {
......
......@@ -38,7 +38,7 @@ class Service {
foreach ($this->getConfigurations()[$this->context->type] as $configuration_class) {
$config = new $configuration_class($this->context, $this);
$config->write();
$this->context->logger->info('Wrote ' . $config->description . ' to ' . $config->filename());
$this->context->application->logger->info('Wrote ' . $config->description . ' to ' . $config->filename());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment