Explorar o código

Update LogglyHandler.php

Updated to add an array_unique to ensure that tags are unique. For backwards compatibility, don't rename the protected property.
barchard %!s(int64=10) %!d(string=hai) anos
pai
achega
5bdba762da
Modificáronse 1 ficheiros con 5 adicións e 5 borrados
  1. 5 5
      src/Monolog/Handler/LogglyHandler.php

+ 5 - 5
src/Monolog/Handler/LogglyHandler.php

@@ -29,7 +29,7 @@ class LogglyHandler extends AbstractProcessingHandler
 
     protected $token;
 
-    protected $tags = array();
+    protected $tag = array();
 
     public function __construct($token, $level = Logger::DEBUG, $bubble = true)
     {
@@ -45,14 +45,14 @@ class LogglyHandler extends AbstractProcessingHandler
     public function setTag($tag)
     {
         $tag = !empty($tag) ? $tag : array();
-        $this->tags = is_array($tag) ? $tag : array($tag);
+        $this->tag = is_array($tag) ? $tag : array($tag);
     }
 
     public function addTag($tag)
     {
         if (!empty($tag)) {
             $tag = is_array($tag) ? $tag : array($tag);
-            $this->tags = array_merge($this->tags, $tag);
+            $this->tag = array_unique(array_merge($this->tag, $tag));
         }
     }
 
@@ -80,8 +80,8 @@ class LogglyHandler extends AbstractProcessingHandler
 
         $headers = array('Content-Type: application/json');
 
-        if (!empty($this->tags)) {
-            $headers[] = 'X-LOGGLY-TAG: '.implode(',', $this->tags);
+        if (!empty($this->tag)) {
+            $headers[] = 'X-LOGGLY-TAG: '.implode(',', $this->tag);
         }
 
         $ch = curl_init();