mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-23 09:36:11 +02:00
use mb_* when needed
This commit is contained in:
@@ -176,7 +176,7 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
|
||||
$args[] = '"font-weight: normal"';
|
||||
|
||||
$pos = $match[0][1];
|
||||
$format = Utils::substr($format, 0, $pos) . '%c' . $match[1][0] . '%c' . Utils::substr($format, $pos + Utils::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));
|
||||
|
@@ -14,7 +14,6 @@ namespace Monolog\Handler;
|
||||
use Monolog\Formatter\ChromePHPFormatter;
|
||||
use Monolog\Formatter\FormatterInterface;
|
||||
use Monolog\Logger;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Handler sending logs to the ChromePHP extension (http://www.chromephp.com/)
|
||||
@@ -147,7 +146,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
|
||||
|
||||
$json = @json_encode(self::$json);
|
||||
$data = base64_encode(utf8_encode($json));
|
||||
if (Utils::strlen($data) > 240 * 1024) {
|
||||
if (strlen($data) > 240 * 1024) {
|
||||
self::$overflowed = true;
|
||||
|
||||
$record = [
|
||||
|
@@ -12,7 +12,6 @@
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Logs to Cube.
|
||||
@@ -135,7 +134,7 @@ class CubeHandler extends AbstractProcessingHandler
|
||||
$this->connectUdp();
|
||||
}
|
||||
|
||||
socket_send($this->udpConnection, $data, Utils::strlen($data), 0);
|
||||
socket_send($this->udpConnection, $data, strlen($data), 0);
|
||||
}
|
||||
|
||||
private function writeHttp(string $data): void
|
||||
@@ -147,7 +146,7 @@ class CubeHandler extends AbstractProcessingHandler
|
||||
curl_setopt($this->httpConnection, CURLOPT_POSTFIELDS, '['.$data.']');
|
||||
curl_setopt($this->httpConnection, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . Utils::strlen('['.$data.']'),
|
||||
'Content-Length: ' . strlen('['.$data.']'),
|
||||
]);
|
||||
|
||||
Curl\Util::execute($this->httpConnection, 5, false);
|
||||
|
@@ -12,7 +12,6 @@
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Simple handler wrapper that deduplicates log records across multiple requests
|
||||
@@ -67,7 +66,7 @@ class DeduplicationHandler extends BufferHandler
|
||||
{
|
||||
parent::__construct($handler, 0, Logger::DEBUG, $bubble, false);
|
||||
|
||||
$this->deduplicationStore = $deduplicationStore === null ? sys_get_temp_dir() . '/monolog-dedup-' . Utils::substr(md5(__FILE__), 0, 20) .'.log' : $deduplicationStore;
|
||||
$this->deduplicationStore = $deduplicationStore === null ? sys_get_temp_dir() . '/monolog-dedup-' . substr(md5(__FILE__), 0, 20) .'.log' : $deduplicationStore;
|
||||
$this->deduplicationLevel = Logger::toMonologLevel($deduplicationLevel);
|
||||
$this->time = $time;
|
||||
}
|
||||
@@ -150,7 +149,7 @@ class DeduplicationHandler extends BufferHandler
|
||||
|
||||
while (!feof($handle)) {
|
||||
$log = fgets($handle);
|
||||
if ($log && Utils::substr($log, 0, 10) >= $timestampValidity) {
|
||||
if ($log && substr($log, 0, 10) >= $timestampValidity) {
|
||||
$validLogs[] = $log;
|
||||
}
|
||||
}
|
||||
|
@@ -14,7 +14,6 @@ namespace Monolog\Handler;
|
||||
use Monolog\Formatter\FormatterInterface;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
use Monolog\Logger;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Sends logs to Fleep.io using Webhook integrations
|
||||
@@ -97,7 +96,7 @@ class FleepHookHandler extends SocketHandler
|
||||
$header = "POST " . static::FLEEP_HOOK_URI . $this->token . " HTTP/1.1\r\n";
|
||||
$header .= "Host: " . static::FLEEP_HOST . "\r\n";
|
||||
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||
$header .= "Content-Length: " . Utils::strlen($content) . "\r\n";
|
||||
$header .= "Content-Length: " . strlen($content) . "\r\n";
|
||||
$header .= "\r\n";
|
||||
|
||||
return $header;
|
||||
|
@@ -14,7 +14,6 @@ namespace Monolog\Handler;
|
||||
use Monolog\Logger;
|
||||
use Monolog\Formatter\FlowdockFormatter;
|
||||
use Monolog\Formatter\FormatterInterface;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Sends notifications through the Flowdock push API
|
||||
@@ -108,7 +107,7 @@ class FlowdockHandler extends SocketHandler
|
||||
$header = "POST /v1/messages/team_inbox/" . $this->apiToken . " HTTP/1.1\r\n";
|
||||
$header .= "Host: api.flowdock.com\r\n";
|
||||
$header .= "Content-Type: application/json\r\n";
|
||||
$header .= "Content-Length: " . Utils::strlen($content) . "\r\n";
|
||||
$header .= "Content-Length: " . strlen($content) . "\r\n";
|
||||
$header .= "\r\n";
|
||||
|
||||
return $header;
|
||||
|
@@ -13,7 +13,6 @@ namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Formatter\FormatterInterface;
|
||||
use Monolog\Formatter\HtmlFormatter;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Base class for all mail handlers
|
||||
@@ -71,7 +70,7 @@ abstract class MailHandler extends AbstractProcessingHandler
|
||||
|
||||
protected function isHtmlBody(string $body): bool
|
||||
{
|
||||
return Utils::substr($body, 0, 1) === '<';
|
||||
return substr($body, 0, 1) === '<';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -116,7 +116,7 @@ class PushoverHandler extends SocketHandler
|
||||
private function buildContent(array $record): string
|
||||
{
|
||||
// Pushover has a limit of 512 characters on title and message combined.
|
||||
$maxMessageLength = 512 - Utils::strlen($this->title);
|
||||
$maxMessageLength = 512 - strlen($this->title);
|
||||
|
||||
$message = ($this->useFormattedMessage) ? $record['formatted'] : $record['message'];
|
||||
$message = Utils::substr($message, 0, $maxMessageLength);
|
||||
@@ -159,7 +159,7 @@ class PushoverHandler extends SocketHandler
|
||||
$header = "POST /1/messages.json HTTP/1.1\r\n";
|
||||
$header .= "Host: api.pushover.net\r\n";
|
||||
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||
$header .= "Content-Length: " . Utils::strlen($content) . "\r\n";
|
||||
$header .= "Content-Length: " . strlen($content) . "\r\n";
|
||||
$header .= "\r\n";
|
||||
|
||||
return $header;
|
||||
|
@@ -14,7 +14,6 @@ namespace Monolog\Handler\Slack;
|
||||
use Monolog\Logger;
|
||||
use Monolog\Formatter\NormalizerFormatter;
|
||||
use Monolog\Formatter\FormatterInterface;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Slack record utility helping to log to Slack webhooks or API.
|
||||
@@ -308,7 +307,7 @@ class SlackRecord
|
||||
private function generateAttachmentField(string $title, $value): array
|
||||
{
|
||||
$value = is_array($value)
|
||||
? sprintf('```%s```', Utils::substr($this->stringify($value), 0, 1990))
|
||||
? sprintf('```%s```', substr($this->stringify($value), 0, 1990))
|
||||
: $value;
|
||||
|
||||
return array(
|
||||
|
@@ -14,7 +14,6 @@ namespace Monolog\Handler;
|
||||
use Monolog\Formatter\FormatterInterface;
|
||||
use Monolog\Logger;
|
||||
use Monolog\Handler\Slack\SlackRecord;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Sends notifications through Slack API
|
||||
@@ -130,7 +129,7 @@ class SlackHandler extends SocketHandler
|
||||
$header = "POST /api/chat.postMessage HTTP/1.1\r\n";
|
||||
$header .= "Host: slack.com\r\n";
|
||||
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||
$header .= "Content-Length: " . Utils::strlen($content) . "\r\n";
|
||||
$header .= "Content-Length: " . strlen($content) . "\r\n";
|
||||
$header .= "\r\n";
|
||||
|
||||
return $header;
|
||||
|
@@ -12,7 +12,6 @@
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Stores to any socket - uses fsockopen() or pfsockopen().
|
||||
@@ -326,7 +325,7 @@ class SocketHandler extends AbstractProcessingHandler
|
||||
|
||||
private function writeToSocket(string $data): void
|
||||
{
|
||||
$length = Utils::strlen($data);
|
||||
$length = strlen($data);
|
||||
$sent = 0;
|
||||
$this->lastSentBytes = $sent;
|
||||
while ($this->isConnected() && $sent < $length) {
|
||||
|
@@ -52,7 +52,7 @@ class SqsHandler extends AbstractProcessingHandler
|
||||
}
|
||||
|
||||
$messageBody = $record['formatted'];
|
||||
if (Utils::strlen($messageBody) >= static::MAX_MESSAGE_SIZE) {
|
||||
if (strlen($messageBody) >= static::MAX_MESSAGE_SIZE) {
|
||||
$messageBody = Utils::substr($messageBody, 0, static::HEAD_MESSAGE_SIZE);
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,6 @@
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Stores to any stream resource
|
||||
@@ -147,8 +146,8 @@ class StreamHandler extends AbstractProcessingHandler
|
||||
return dirname($stream);
|
||||
}
|
||||
|
||||
if ('file://' === Utils::substr($stream, 0, 7)) {
|
||||
return dirname(Utils::substr($stream, 7));
|
||||
if ('file://' === substr($stream, 0, 7)) {
|
||||
return dirname(substr($stream, 7));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@@ -49,12 +49,12 @@ class UdpSocket
|
||||
if (!is_resource($this->socket)) {
|
||||
throw new \RuntimeException('The UdpSocket to '.$this->ip.':'.$this->port.' has been closed and can not be written to anymore');
|
||||
}
|
||||
socket_sendto($this->socket, $chunk, Utils::strlen($chunk), $flags = 0, $this->ip, $this->port);
|
||||
socket_sendto($this->socket, $chunk, strlen($chunk), $flags = 0, $this->ip, $this->port);
|
||||
}
|
||||
|
||||
protected function assembleMessage(string $line, string $header): string
|
||||
{
|
||||
$chunkSize = static::DATAGRAM_MAX_LENGTH - Utils::strlen($header);
|
||||
$chunkSize = static::DATAGRAM_MAX_LENGTH - strlen($header);
|
||||
|
||||
return $header . Utils::substr($line, 0, $chunkSize);
|
||||
}
|
||||
|
Reference in New Issue
Block a user