1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-02-22 14:03:29 +01:00

Merge pull request #557 from barchard/patch-1

Update LogglyHandler.php
This commit is contained in:
Jordi Boggiano 2015-06-01 22:12:22 +01:00
commit 81e91932bf

View File

@ -19,6 +19,7 @@ use Monolog\Formatter\LogglyFormatter;
*
* @author Przemek Sobstel <przemek@sobstel.org>
* @author Adam Pancutt <adam@pancutt.com>
* @author Gregory Barchard <gregory@barchard.net>
*/
class LogglyHandler extends AbstractProcessingHandler
{
@ -28,7 +29,7 @@ class LogglyHandler extends AbstractProcessingHandler
protected $token;
protected $tag;
protected $tag = array();
public function __construct($token, $level = Logger::DEBUG, $bubble = true)
{
@ -43,12 +44,16 @@ class LogglyHandler extends AbstractProcessingHandler
public function setTag($tag)
{
$this->tag = $tag;
$tag = !empty($tag) ? $tag : array();
$this->tag = is_array($tag) ? $tag : array($tag);
}
public function addTag($tag)
{
$this->tag = (strlen($this->tag) > 0) ? $this->tag .','. $tag : $tag;
if (!empty($tag)) {
$tag = is_array($tag) ? $tag : array($tag);
$this->tag = array_unique(array_merge($this->tag, $tag));
}
}
protected function write(array $record)
@ -75,8 +80,8 @@ class LogglyHandler extends AbstractProcessingHandler
$headers = array('Content-Type: application/json');
if ($this->tag) {
$headers[] = "X-LOGGLY-TAG: {$this->tag}";
if (!empty($this->tag)) {
$headers[] = 'X-LOGGLY-TAG: '.implode(',', $this->tag);
}
$ch = curl_init();