Parcourir la source

Cosmetic fixes

Jordi Boggiano il y a 13 ans
Parent
commit
89b5a3caac
3 fichiers modifiés avec 42 ajouts et 39 suppressions
  1. 3 5
      README.mdown
  2. 26 24
      composer.json
  3. 13 10
      src/Monolog/Handler/AmqpHandler.php

+ 3 - 5
README.mdown

@@ -106,14 +106,13 @@ Handlers
   [Mongo](http://pecl.php.net/package/mongo) extension connection.
 - _NativeMailHandler_: Sends emails using PHP's
   [`mail()`](http://php.net/manual/en/function.mail.php) function.
-- _SwiftMailerHandler_: Sends emails using a `Swift_Mailer` instance.
+- _SwiftMailerHandler_: Sends emails using a [`Swift_Mailer`](http://swiftmailer.org/) instance.
 - _SyslogHandler_: Logs records to the syslog.
 - _GelfHandler_: Logs records to a [Graylog2](http://www.graylog2.org) server.
 - _SocketHandler_: Logs records to [sockets](http://php.net/fsockopen), use this
   for UNIX and TCP sockets. See an [example](https://github.com/Seldaek/monolog/blob/master/doc/sockets.md).
-- _AmqpHandler_L Logs records using [amqp](php.net/manual/en/book.amqp.php) protocol to the RabbitMQ server.
-  Note: handler needs an installed amqp version > 1.
-  For instructions on installation look in (http://lv.php.net/manual/en/amqp.installation.php)
+- _AmqpHandler_: Logs records to an [amqp](http://www.amqp.org/) compatible
+  server. Requires the [php-amqp](http://pecl.php.net/package/amqp) extension (1.0+).
 
 Wrappers / Special Handlers
 ---------------------------
@@ -164,7 +163,6 @@ Requirements
 
 - Any flavor of PHP 5.3 should do
 - [optional] PHPUnit 3.5+ to execute the test suite (phpunit --version)
-- [optional] installed amqp library to use AmqpHandler.
 
 Submitting bugs and feature requests
 ------------------------------------

+ 26 - 24
composer.json

@@ -1,27 +1,29 @@
 {
-  "name": "monolog/monolog",
-  "description": "Logging for PHP 5.3",
-  "keywords": ["log","logging"],
-  "homepage": "http://github.com/Seldaek/monolog",
-  "type": "library",
-  "license": "MIT",
-  "authors": [
-    {
-      "name": "Jordi Boggiano",
-      "email": "j.boggiano@seld.be",
-      "homepage": "http://seld.be"
+    "name": "monolog/monolog",
+    "description": "Logging for PHP 5.3",
+    "keywords": ["log","logging"],
+    "homepage": "http://github.com/Seldaek/monolog",
+    "type": "library",
+    "license": "MIT",
+    "authors": [
+        {
+            "name": "Jordi Boggiano",
+            "email": "j.boggiano@seld.be",
+            "homepage": "http://seld.be"
+        }
+    ],
+    "require": {
+        "php": ">=5.3.0"
+    },
+    "require-dev": {
+        "mlehner/gelf-php": "1.0.*"
+    },
+    "suggest": {
+        "mlehner/gelf-php": "Allow sending log messages to a GrayLog2 server",
+        "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
+        "ext-mongo": "Allow sending log messages to a MongoDB server"
+    },
+    "autoload": {
+        "psr-0": {"Monolog": "src/"}
     }
-  ],
-  "require": {
-    "php": ">=5.3.0"
-  },
-  "require-dev": {
-    "mlehner/gelf-php": "1.0.*"
-  },
-  "suggest": {
-    "mlehner/gelf-php": "Allow sending log messages to a GrayLog2 server"
-  },
-  "autoload": {
-    "psr-0": {"Monolog": "src/"}
-  }
 }

+ 13 - 10
src/Monolog/Handler/AmqpHandler.php

@@ -22,11 +22,11 @@ class AmqpHandler extends AbstractProcessingHandler
     protected $exchange;
 
     /**
-     * @param \AMQPExchange $exchange AMQP exchange, ready for use
-     * @param string $exchangeName
-     * @param string $issuer isser name
-     * @param int $level
-     * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
+     * @param \AMQPExchange $exchange     AMQP exchange, ready for use
+     * @param string        $exchangeName
+     * @param string        $issuer       issuer name
+     * @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', $level = Logger::DEBUG, $bubble = true)
     {
@@ -43,18 +43,21 @@ class AmqpHandler extends AbstractProcessingHandler
     {
         $data = $record["formatted"];
 
-        $routingKey = sprintf('%s.%s',
+        $routingKey = sprintf(
+            '%s.%s',
             substr($record['level_name'], 0, 4),
-            $record['channel']);
+            $record['channel']
+        );
 
-        //we do not check return value because no handler really does
-        $this->exchange->publish($data,
+        $this->exchange->publish(
+            $data,
             strtolower($routingKey),
             0,
             array(
                 'delivery_mode' => 2,
                 'Content-type' => 'application/json'
-            ));
+            )
+        );
     }
 
     /**