Просмотр исходного кода

get issuer name from record param channel, instead of passing it through handler constructor

pomaxa 13 лет назад
Родитель
Сommit
6b4f4af85f
3 измененных файлов с 31 добавлено и 28 удалено
  1. 28 0
      pharIt.php
  2. 2 27
      src/Monolog/Handler/AmqpHandler.php
  3. 1 1
      tests/Monolog/Handler/AmqpHandlerTest.php

+ 28 - 0
pharIt.php

@@ -0,0 +1,28 @@
+#!/usr/bin/env php
+<?php
+
+$phar = new Phar('monolog.phar', 0, 'logger');
+$phar->setSignatureAlgorithm(Phar::SHA1);
+
+$phar->startBuffering();
+
+$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__.'/src/Monolog', FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST);
+foreach ($files as $file) {
+    if (false !== strpos($file->getRealPath(), '.git')) {
+        continue;
+    }
+
+    $path = str_replace(realpath(__DIR__).'/', '', $file->getRealPath());
+    $phar->addFile($file->getRealPath(), $path);
+
+    echo "$path\n";
+}
+
+$phar->addFile('src/Monolog/Logger.php');
+
+$phar->setDefaultStub('src/Monolog/Logger.php', 'Logger.php');
+
+$phar->stopBuffering();
+$phar->compressFiles(Phar::GZ);
+
+unset($phar);

+ 2 - 27
src/Monolog/Handler/AmqpHandler.php

@@ -21,12 +21,6 @@ class AmqpHandler extends AbstractProcessingHandler
      */
     protected $exchange;
 
-    /**
-     * Describes current issuer (e.g. "database", "landing", "server" and so on)
-     * @var string $issuer
-     */
-    protected $issuer;
-
     /**
      * @param \AMQPExchange $exchange AMQP exchange, ready for use
      * @param string $exchangeName
@@ -34,9 +28,8 @@ class AmqpHandler extends AbstractProcessingHandler
      * @param int $level
      * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
      */
-    public function __construct(\AMQPExchange $exchange, $exchangeName = 'log', $issuer = 'default', $level = Logger::DEBUG, $bubble = true)
+    public function __construct(\AMQPExchange $exchange, $exchangeName = 'log', $level = Logger::DEBUG, $bubble = true)
     {
-        $this->issuer = $issuer;
         $this->exchange = $exchange;
         $this->exchange->setName($exchangeName);
 
@@ -55,7 +48,7 @@ class AmqpHandler extends AbstractProcessingHandler
 
         $routingKey = sprintf('%s.%s',
             substr($record['level_name'], 0, 4),
-            $this->getIssuer());
+            $record['channel']);
 
         //we do not check return value because no handler really does
         $this->exchange->publish($data,
@@ -74,22 +67,4 @@ class AmqpHandler extends AbstractProcessingHandler
     {
         return new JsonFormatter();
     }
-
-    /**
-     * Issuer setter
-     * @param string $issuer
-     */
-    public function setIssuer($issuer)
-    {
-        $this->issuer = $issuer;
-    }
-
-    /**
-     * Issuer getter
-     * @return string
-     */
-    public function getIssuer()
-    {
-        return $this->issuer;
-    }
 }

+ 1 - 1
tests/Monolog/Handler/AmqpHandlerTest.php

@@ -34,7 +34,7 @@ class AmqpHandlerTest extends TestCase
     {
         $exchange = $this->getExchange();
 
-        $handler = new AmqpHandler($exchange, 'log', 'test');
+        $handler = new AmqpHandler($exchange, 'log');
 
         $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));