blob: 5e929bc1b7baff577eee2990ab7ce3392f34a5e7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
---
layout: doc
---
# Message Logging
Records channel chat messages in NDJSON (Newline Delimited JSON) format to files. This feature is available when channel chat is enabled and is turned on by default.
## Configuration
```yaml
# config.yml
features:
channelChat:
enabled: true
messageLogging:
enabled: true
retentionDays: 30
maxFileSizeMB: 100
```
| Setting Key | Default | Description |
|-------------|---------|-------------|
| `enabled` | `true` | Enable message logging |
| `retentionDays` | `30` | Number of days to retain log files (`0` for unlimited retention) |
| `maxFileSizeMB` | `100` | Maximum size of a single log file (MB) |
## Log File Format
Log files are saved in the `plugins/LunaticChat/logs/` directory. Each line is a single JSON object.
### File Naming
```
channel-messages-YYYY-MM-dd.json
```
When the file size exceeds `maxFileSizeMB`, a new file with a suffix is created.
```
channel-messages-2026-04-05.json # Base file
channel-messages-2026-04-05-1.json # On size overflow
channel-messages-2026-04-05-2.json # On further overflow
```
### Entry Format
Each line has the following JSON structure.
```json
{
"timestamp": "2026-04-05T14:23:45.123Z",
"playerId": "550e8400-e29b-41d4-a716-446655440000",
"playerName": "Steve",
"channelId": "general",
"message": "Hello everyone!"
}
```
| Field | Type | Description |
|-------|------|-------------|
| `timestamp` | String | ISO 8601 timestamp (UTC) |
| `playerId` | String | Player UUID |
| `playerName` | String | Player display name |
| `channelId` | String | ID of the channel the message was sent to |
| `message` | String | Message content |
## File Rotation
- **Daily rotation**: A new file is created when the date changes
- **Size rotation**: Switches to a suffixed file when `maxFileSizeMB` is exceeded
- **Automatic cleanup**: Log files older than the number of days specified by `retentionDays` are automatically deleted (no deletion when set to `0`)
## Usage Examples
Since the format is NDJSON, you can easily filter and aggregate logs using tools like `jq`.
### Extract Messages from a Specific Channel
```bash
jq 'select(.channelId == "general")' channel-messages-2026-04-05.json
```
### Extract Messages from a Specific Player
```bash
jq 'select(.playerName == "Steve")' channel-messages-2026-04-05.json
```
### Count Messages by Channel
```bash
jq -s 'group_by(.channelId) | map({channel: .[0].channelId, count: length})' channel-messages-2026-04-05.json
```
|