16
16
use CodeIgniter\HTTP\ResponseInterface;
17
17
18
18
/**
19
- * Class ChromeLoggerHandler
20
- *
21
19
* Allows for logging items to the Chrome console for debugging.
22
20
* Requires the ChromeLogger extension installed in your browser.
23
21
*
@@ -41,7 +39,16 @@ class ChromeLoggerHandler extends BaseHandler
41
39
/**
42
40
* The final data that is sent to the browser.
43
41
*
44
- * @var array
42
+ * @var array{
43
+ * version: float,
44
+ * columns: list<string>,
45
+ * rows: list<array{
46
+ * 0: list<string>,
47
+ * 1: string,
48
+ * 2: string,
49
+ * }>,
50
+ * request_uri?: string,
51
+ * }
45
52
*/
46
53
protected $json = [
47
54
'version' => self::VERSION,
@@ -63,7 +70,7 @@ class ChromeLoggerHandler extends BaseHandler
63
70
/**
64
71
* Maps the log levels to the ChromeLogger types.
65
72
*
66
- * @var array
73
+ * @var array<string, string>
67
74
*/
68
75
protected $levels = [
69
76
'emergency' => 'error',
@@ -77,7 +84,7 @@ class ChromeLoggerHandler extends BaseHandler
77
84
];
78
85
79
86
/**
80
- * Constructor
87
+ * @param array{handles?: list<string>} $config
81
88
*/
82
89
public function __construct(array $config = [])
83
90
{
@@ -97,10 +104,8 @@ public function __construct(array $config = [])
97
104
*/
98
105
public function handle($level, $message): bool
99
106
{
100
- // Format our message
101
107
$message = $this->format($message);
102
108
103
- // Generate Backtrace info
104
109
$backtrace = debug_backtrace(0, $this->backtraceLevel);
105
110
$backtrace = end($backtrace);
106
111
@@ -116,11 +121,7 @@ public function handle($level, $message): bool
116
121
$type = $this->levels[$level];
117
122
}
118
123
119
- $this->json['rows'][] = [
120
- [$message],
121
- $backtraceMessage,
122
- $type,
123
- ];
124
+ $this->json['rows'][] = [[$message], $backtraceMessage, $type];
124
125
125
126
$this->sendLogs();
126
127
@@ -130,9 +131,9 @@ public function handle($level, $message): bool
130
131
/**
131
132
* Converts the object to display nicely in the Chrome Logger UI.
132
133
*
133
- * @param array|int| object|string $object
134
+ * @param object|string $object
134
135
*
135
- * @return array
136
+ * @return array<string, mixed>|string
136
137
*/
137
138
protected function format($object)
138
139
{
0 commit comments