1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-22 09:06:10 +02:00

Merge pull request #1290 from versh23/fix-gelp-formtatter

use mb_ functions everywhere if possible
This commit is contained in:
Jordi Boggiano
2019-08-30 11:20:47 +02:00
committed by GitHub
14 changed files with 77 additions and 23 deletions

View File

@@ -13,6 +13,7 @@ namespace Monolog\Handler;
use Monolog\Formatter\LineFormatter;
use Monolog\Formatter\FormatterInterface;
use Monolog\Utils;
/**
* Handler sending logs to browser's javascript console with no browser extension required
@@ -175,7 +176,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
$args[] = '"font-weight: normal"';
$pos = $match[0][1];
$format = substr($format, 0, $pos) . '%c' . $match[1][0] . '%c' . substr($format, $pos + strlen($match[0][0]));
$format = Utils::substr($format, 0, $pos) . '%c' . $match[1][0] . '%c' . Utils::substr($format, $pos + strlen($match[0][0]));
}
array_unshift($args, static::quote($format));

View File

@@ -31,9 +31,9 @@ final class Util
/**
* Executes a CURL request with optional retries and exception on failure
*
* @param resource $ch curl handler
* @param int $retries
* @param bool $closeAfterDone
* @param resource $ch curl handler
* @param int $retries
* @param bool $closeAfterDone
* @return bool|string @see curl_exec
*/
public static function execute($ch, int $retries = 5, bool $closeAfterDone = true)
@@ -65,4 +65,4 @@ final class Util
return false;
}
}
}

View File

@@ -13,7 +13,6 @@ namespace Monolog\Handler;
use Monolog\Logger;
/**
* Handler to only pass log messages when a certain threshold of number of messages is reached.
*
@@ -60,9 +59,9 @@ class OverflowHandler extends AbstractHandler
/**
* @param HandlerInterface $handler
* @param int[] $thresholdMap Dictionary of logger level => threshold
* @param int $level
* @param bool $bubble
* @param int[] $thresholdMap Dictionary of logger level => threshold
* @param int $level
* @param bool $bubble
*/
public function __construct(
HandlerInterface $handler,
@@ -87,7 +86,7 @@ class OverflowHandler extends AbstractHandler
* Unless the bubbling is interrupted (by returning true), the Logger class will keep on
* calling further handlers in the stack with a given log record.
*
* @param array $record The record to handle
* @param array $record The record to handle
*
* @return Boolean true means that this handler handled the record, and that bubbling is not permitted.
* false means the record was either not processed or that this handler allows bubbling.
@@ -108,6 +107,7 @@ class OverflowHandler extends AbstractHandler
// The overflow threshold is not yet reached, so we're buffering the record and lowering the threshold by 1
$this->thresholdMap[$level]--;
$this->buffer[$level][] = $record;
return false === $this->bubble;
}

View File

@@ -12,6 +12,7 @@
namespace Monolog\Handler;
use Monolog\Logger;
use Monolog\Utils;
/**
* Sends notifications through the pushover api to mobile phones
@@ -118,7 +119,7 @@ class PushoverHandler extends SocketHandler
$maxMessageLength = 512 - strlen($this->title);
$message = ($this->useFormattedMessage) ? $record['formatted'] : $record['message'];
$message = substr($message, 0, $maxMessageLength);
$message = Utils::substr($message, 0, $maxMessageLength);
$timestamp = $record['datetime']->getTimestamp();

View File

@@ -13,6 +13,7 @@ namespace Monolog\Handler;
use Aws\Sqs\SqsClient;
use Monolog\Logger;
use Monolog\Utils;
/**
* Writes to any sqs queue.
@@ -52,7 +53,7 @@ class SqsHandler extends AbstractProcessingHandler
$messageBody = $record['formatted'];
if (strlen($messageBody) >= static::MAX_MESSAGE_SIZE) {
$messageBody = substr($messageBody, 0, static::HEAD_MESSAGE_SIZE);
$messageBody = Utils::substr($messageBody, 0, static::HEAD_MESSAGE_SIZE);
}
$this->client->sendMessage([

View File

@@ -11,6 +11,8 @@
namespace Monolog\Handler\SyslogUdp;
use Monolog\Utils;
class UdpSocket
{
protected const DATAGRAM_MAX_LENGTH = 65023;
@@ -54,6 +56,6 @@ class UdpSocket
{
$chunkSize = static::DATAGRAM_MAX_LENGTH - strlen($header);
return $header . substr($line, 0, $chunkSize);
return $header . Utils::substr($line, 0, $chunkSize);
}
}

View File

@@ -1,4 +1,13 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.
*
* (c) Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Monolog\Handler;
@@ -38,7 +47,7 @@ class TelegramBotHandler extends AbstractProcessingHandler
private $channel;
/**
* @param string $apiKey Telegram bot access token provided by BotFather
* @param string $apiKey Telegram bot access token provided by BotFather
* @param string $channel Telegram channel name
* @inheritDoc
*/
@@ -87,4 +96,4 @@ class TelegramBotHandler extends AbstractProcessingHandler
throw new RuntimeException('Telegram API error. Description: ' . $result['description']);
}
}
}
}