Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 4c64493

Browse files
committed
Improved loggin display
1 parent 22fcddb commit 4c64493

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

resources/views/dashboard.blade.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,14 @@
7070
<thead>
7171
<tr>
7272
<th>Type</th>
73-
<th>Socket</th>
7473
<th>Details</th>
7574
<th>Time</th>
7675
</tr>
7776
</thead>
7877
<tbody>
7978
<tr v-for="log in logs.slice().reverse()">
8079
<td><span class="badge" :class="getBadgeClass(log)">@{{ log.type }}</span></td>
81-
<td>@{{ log.socketId }}</td>
82-
<td>@{{ log.details }}</td>
80+
<td><pre>@{{ log.details }}</pre></td>
8381
<td>@{{ log.time }}</td>
8482
</tr>
8583
</tbody>

src/Dashboard/DashboardLogger.php

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,68 +34,91 @@ public static function connection(ConnectionInterface $connection)
3434
$request = $connection->httpRequest;
3535

3636
static::log($connection->app->id, static::TYPE_CONNECTION, [
37-
'details' => "Origin: {$request->getUri()->getScheme()}://{$request->getUri()->getHost()}",
38-
'socketId' => $connection->socketId,
37+
'details' => [
38+
'origin' => "{$request->getUri()->getScheme()}://{$request->getUri()->getHost()}",
39+
'socketId' => $connection->socketId,
40+
],
3941
]);
4042
}
4143

4244
public static function occupied(ConnectionInterface $connection, string $channelName)
4345
{
4446
static::log($connection->app->id, static::TYPE_OCCUPIED, [
45-
'details' => "Channel: {$channelName}",
47+
'details' => [
48+
'channel' => $channelName,
49+
],
4650
]);
4751
}
4852

4953
public static function subscribed(ConnectionInterface $connection, string $channelName)
5054
{
5155
static::log($connection->app->id, static::TYPE_SUBSCRIBED, [
52-
'socketId' => $connection->socketId,
53-
'details' => "Channel: {$channelName}",
56+
'details' => [
57+
'socketId' => $connection->socketId,
58+
'channel' => $channelName,
59+
],
5460
]);
5561
}
5662

5763
public static function clientMessage(ConnectionInterface $connection, stdClass $payload)
5864
{
5965
static::log($connection->app->id, static::TYPE_CLIENT_MESSAGE, [
60-
'details' => "Channel: {$payload->channel}, Event: {$payload->event}",
61-
'socketId' => $connection->socketId,
62-
'data' => json_encode($payload),
66+
'details' => [
67+
'socketId' => $connection->socketId,
68+
'channel' => $payload->channel,
69+
'event' => $payload->event,
70+
'data' => $payload,
71+
],
6372
]);
6473
}
6574

6675
public static function disconnection(ConnectionInterface $connection)
6776
{
6877
static::log($connection->app->id, static::TYPE_DISCONNECTION, [
69-
'socketId' => $connection->socketId,
78+
'details' => [
79+
'socketId' => $connection->socketId,
80+
],
7081
]);
7182
}
7283

7384
public static function vacated(ConnectionInterface $connection, string $channelName)
7485
{
7586
static::log($connection->app->id, static::TYPE_VACATED, [
76-
'details' => "Channel: {$channelName}",
87+
'details' => [
88+
'socketId' => $connection->socketId,
89+
'channel' => $channelName,
90+
],
7791
]);
7892
}
7993

8094
public static function apiMessage($appId, string $channel, string $event, string $payload)
8195
{
8296
static::log($appId, static::TYPE_API_MESSAGE, [
83-
'details' => "Channel: {$channel}, Event: {$event}",
84-
'data' => $payload,
97+
'details' => [
98+
'channel' => $connection,
99+
'event' => $event,
100+
'payload' => $payload,
101+
],
85102
]);
86103
}
87104

88105
public static function replicatorSubscribed(string $appId, string $channel, string $serverId)
89106
{
90107
static::log($appId, static::TYPE_REPLICATOR_SUBSCRIBED, [
91-
'details' => "Server ID: {$serverId} on Channel: {$channel}",
108+
'details' => [
109+
'serverId' => $serverId,
110+
'channel' => $channel,
111+
],
92112
]);
93113
}
94114

95115
public static function replicatorUnsubscribed(string $appId, string $channel, string $serverId)
96116
{
97117
static::log($appId, static::TYPE_REPLICATOR_UNSUBSCRIBED, [
98-
'details' => "Server ID: {$serverId} on Channel: {$channel}",
118+
'details' => [
119+
'serverId' => $serverId,
120+
'channel' => $channel,
121+
],
99122
]);
100123
}
101124

0 commit comments

Comments
 (0)