Permalink
Browse files

Adding LoggerChain.

  • Loading branch information...
1 parent d029025 commit ba5fd872b2b46e749b20c2d65e80f1bb3189a73b @jhuet jhuet committed Dec 1, 2012
Showing with 53 additions and 1 deletion.
  1. +51 −0 src/DoctrineMongoODMModule/Logging/LoggerChain.php
  2. +2 −1 src/DoctrineMongoODMModule/Module.php
@@ -0,0 +1,51 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+namespace DoctrineMongoODMModule\Logging;
+
+/**
+ * Chains multiple Logger
+ *
+ * @license MIT
+ * @link www.doctrine-project.org
+ */
+class LoggerChain implements Logger
+{
+ private $loggers = array();
+
+ /**
+ * Adds a logger in the chain
+ *
+ * @param Logger $logger
+ */
+ public function addLogger(Logger $logger)
+ {
+ $this->loggers[] = $logger;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function log(array $logs)
+ {
+ foreach ($this->loggers as $logger) {
+ $logger->log($logs);
+ }
+ }
+}
+
@@ -103,7 +103,8 @@ public function getServiceConfig()
{
return array(
'invokables' => array(
- 'DoctrineMongoODMModule\Logging\DebugStack' => 'DoctrineMongoODMModule\Logging\DebugStack',
+ 'DoctrineMongoODMModule\Logging\DebugStack' => 'DoctrineMongoODMModule\Logging\DebugStack',
+ 'DoctrineMongoODMModule\Logging\LoggerChain' => 'DoctrineMongoODMModule\Logging\LoggerChain',
),
'aliases' => array(
'Doctrine\ODM\Mongo\DocumentManager' => 'doctrine.documentmanager.odm_default',

0 comments on commit ba5fd87

Please sign in to comment.