summaryrefslogtreecommitdiffstats
path: root/src/Monolog/Handler/ChromePHPHandler.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Monolog/Handler/ChromePHPHandler.php')
-rw-r--r--src/Monolog/Handler/ChromePHPHandler.php59
1 files changed, 17 insertions, 42 deletions
diff --git a/src/Monolog/Handler/ChromePHPHandler.php b/src/Monolog/Handler/ChromePHPHandler.php
index 785cb0c..4c6be69 100644
--- a/src/Monolog/Handler/ChromePHPHandler.php
+++ b/src/Monolog/Handler/ChromePHPHandler.php
@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.
@@ -12,6 +12,7 @@
namespace Monolog\Handler;
use Monolog\Formatter\ChromePHPFormatter;
+use Monolog\Formatter\FormatterInterface;
use Monolog\Logger;
/**
@@ -32,7 +33,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
* Header name
*/
const HEADER_NAME = 'X-ChromeLogger-Data';
-
+
/**
* Regular expression to detect supported browsers (matches any Chrome, or Firefox 43+)
*/
@@ -49,11 +50,11 @@ class ChromePHPHandler extends AbstractProcessingHandler
*/
protected static $overflowed = false;
- protected static $json = array(
+ protected static $json = [
'version' => self::VERSION,
- 'columns' => array('label', 'log', 'backtrace', 'type'),
- 'rows' => array(),
- );
+ 'columns' => ['label', 'log', 'backtrace', 'type'],
+ 'rows' => [],
+ ];
protected static $sendHeaders = true;
@@ -74,7 +75,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
*/
public function handleBatch(array $records)
{
- $messages = array();
+ $messages = [];
foreach ($records as $record) {
if ($record['level'] < $this->level) {
@@ -93,7 +94,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
/**
* {@inheritDoc}
*/
- protected function getDefaultFormatter()
+ protected function getDefaultFormatter(): FormatterInterface
{
return new ChromePHPFormatter();
}
@@ -131,7 +132,7 @@ class ChromePHPHandler extends AbstractProcessingHandler
return;
}
- self::$json['request_uri'] = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
+ self::$json['request_uri'] = $_SERVER['REQUEST_URI'] ?? '';
}
$json = @json_encode(self::$json);
@@ -139,15 +140,15 @@ class ChromePHPHandler extends AbstractProcessingHandler
if (strlen($data) > 240 * 1024) {
self::$overflowed = true;
- $record = array(
+ $record = [
'message' => 'Incomplete logs, chrome header size limit reached',
- 'context' => array(),
+ 'context' => [],
'level' => Logger::WARNING,
'level_name' => Logger::getLevelName(Logger::WARNING),
'channel' => 'monolog',
- 'datetime' => new \DateTime(),
- 'extra' => array(),
- );
+ 'datetime' => new \DateTimeImmutable(),
+ 'extra' => [],
+ ];
self::$json['rows'][count(self::$json['rows']) - 1] = $this->getFormatter()->format($record);
$json = @json_encode(self::$json);
$data = base64_encode(utf8_encode($json));
@@ -173,39 +174,13 @@ class ChromePHPHandler extends AbstractProcessingHandler
/**
* Verifies if the headers are accepted by the current user agent
- *
- * @return Boolean
*/
- protected function headersAccepted()
+ protected function headersAccepted(): bool
{
if (empty($_SERVER['HTTP_USER_AGENT'])) {
return false;
}
- return preg_match(self::USER_AGENT_REGEX, $_SERVER['HTTP_USER_AGENT']);
- }
-
- /**
- * BC getter for the sendHeaders property that has been made static
- */
- public function __get($property)
- {
- if ('sendHeaders' !== $property) {
- throw new \InvalidArgumentException('Undefined property '.$property);
- }
-
- return static::$sendHeaders;
- }
-
- /**
- * BC setter for the sendHeaders property that has been made static
- */
- public function __set($property, $value)
- {
- if ('sendHeaders' !== $property) {
- throw new \InvalidArgumentException('Undefined property '.$property);
- }
-
- static::$sendHeaders = $value;
+ return preg_match(self::USER_AGENT_REGEX, $_SERVER['HTTP_USER_AGENT']) === 1;
}
}