summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Pugh2017-10-24 18:34:50 (GMT)
committerJon Pugh2017-10-24 18:34:50 (GMT)
commit9b111b2a2372aac2172f0c8d8f33fe688c85b312 (patch)
tree1324a674bbb079d30c8f229c8e0521f20e0f91ab
parent8cd03625bc1d883361f6f719b129915d0f5b5efb (diff)
Add logger to Context class and implement when writing configs.
-rw-r--r--composer.json1
-rw-r--r--composer.lock2
-rw-r--r--src/Command.php2
-rw-r--r--src/Context.php8
-rw-r--r--src/Service.php1
5 files changed, 12 insertions, 2 deletions
diff --git a/composer.json b/composer.json
index c3f078d..2d63c44 100644
--- a/composer.json
+++ b/composer.json
@@ -8,6 +8,7 @@
"require": {
"consolidation/annotated-command": "~2",
"drupal/console-core": "1.0.2",
+ "psr/log": "^1.0",
"psy/psysh": "^0.8.11",
"symfony/console": "^3.3",
"symfony/yaml": "^3.3"
diff --git a/composer.lock b/composer.lock
index 02c47ed..fe25733 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "content-hash": "c8f06b1cc28f9638bdc92415ed78c328",
+ "content-hash": "25f4161ac19dde865bcef9fa9d341b03",
"packages": [
{
"name": "consolidation/annotated-command",
diff --git a/src/Command.php b/src/Command.php
index 9ced4f1..bff8a29 100644
--- a/src/Command.php
+++ b/src/Command.php
@@ -6,6 +6,7 @@ use Drupal\Console\Core\Style\DrupalStyle;
use Symfony\Component\Console\Command\Command as BaseCommand;
use Drupal\Console\Core\Command\Shared\CommandTrait;
use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Logger\ConsoleLogger;
use Symfony\Component\Console\Output\OutputInterface;
/**
@@ -69,6 +70,7 @@ 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);
}
catch (\Exception $e) {
diff --git a/src/Context.php b/src/Context.php
index 7237efb..f2bb85e 100644
--- a/src/Context.php
+++ b/src/Context.php
@@ -6,6 +6,7 @@
namespace Aegir\Provision;
+use Psr\Log\LoggerInterface;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Filesystem\Exception\IOException;
@@ -48,7 +49,12 @@ class Context
* init(), set defaults with setProperty().
*/
protected $properties = [];
-
+
+ /**
+ * @var LoggerInterface
+ */
+ public $logger;
+
/**
* Context constructor.
*
diff --git a/src/Service.php b/src/Service.php
index 29849bb..756dfea 100644
--- a/src/Service.php
+++ b/src/Service.php
@@ -38,6 +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->notice('Wrote ' . $config->description . ' to ' . $config->filename());
}
}