فهرست منبع

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 10 سال پیش
والد
کامیت
5bdba762da
1فایلهای تغییر یافته به همراه5 افزوده شده و 5 حذف شده
  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 $token;
 
 
-    protected $tags = array();
+    protected $tag = array();
 
 
     public function __construct($token, $level = Logger::DEBUG, $bubble = true)
     public function __construct($token, $level = Logger::DEBUG, $bubble = true)
     {
     {
@@ -45,14 +45,14 @@ class LogglyHandler extends AbstractProcessingHandler
     public function setTag($tag)
     public function setTag($tag)
     {
     {
         $tag = !empty($tag) ? $tag : array();
         $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)
     public function addTag($tag)
     {
     {
         if (!empty($tag)) {
         if (!empty($tag)) {
             $tag = is_array($tag) ? $tag : array($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');
         $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();
         $ch = curl_init();