teemux 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +24 -0
- package/README.md +167 -0
- package/dist/teemux.d.ts +1 -0
- package/dist/teemux.js +774 -0
- package/dist/teemux.js.map +1 -0
- package/package.json +68 -0
- package/src/LogServer.ts +612 -0
- package/src/ansi-to-html.d.ts +17 -0
- package/src/teemux.ts +303 -0
- package/src/testing/runWithTeemux.ts +113 -0
- package/src/utils/highlightJson.test.ts +205 -0
- package/src/utils/highlightJson.ts +118 -0
- package/src/utils/linkifyUrls.test.ts +168 -0
- package/src/utils/linkifyUrls.ts +24 -0
- package/src/utils/matchesFilters.test.ts +203 -0
- package/src/utils/matchesFilters.ts +65 -0
- package/src/utils/stripAnsi.test.ts +64 -0
- package/src/utils/stripAnsi.ts +8 -0
- package/src/utils/stripHtmlTags.ts +6 -0
- package/src/utils/unescapeHtml.ts +12 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Copyright (c) 2026, Gajus Kuizinas (https://gajus.com/)
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
* Redistributions of source code must retain the above copyright
|
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
|
8
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
|
10
|
+
documentation and/or other materials provided with the distribution.
|
|
11
|
+
* Neither the name of the Gajus Kuizinas (https://gajus.com/) nor the
|
|
12
|
+
names of its contributors may be used to endorse or promote products
|
|
13
|
+
derived from this software without specific prior written permission.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
16
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL GAJUS KUIZINAS BE LIABLE FOR ANY
|
|
19
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
20
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
21
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
22
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
24
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# teemux
|
|
2
|
+
|
|
3
|
+
Aggregate logs from multiple processes in a single view – in browser or terminal.
|
|
4
|
+
|
|
5
|
+
## Motivation
|
|
6
|
+
|
|
7
|
+
* Needed a simple way to browse logs aggregated across multiple processes.
|
|
8
|
+
* Needed a simple way to give agents a unified view of all the logs.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g teemux
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
teemux --name api -- node api.js
|
|
20
|
+
teemux --name worker -- node worker.js
|
|
21
|
+
teemux -- redis-server # name defaults to "redis-server"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The first process starts a local server on port 8336. Others connect automatically.
|
|
25
|
+
|
|
26
|
+
### Options
|
|
27
|
+
|
|
28
|
+
| Option | Alias | Default | Description |
|
|
29
|
+
|--------|-------|---------|-------------|
|
|
30
|
+
| `--name` | `-n` | command name | Identifier for this process in logs |
|
|
31
|
+
| `--port` | `-p` | 8336 | Port for the log aggregation server |
|
|
32
|
+
| `--tail` | `-t` | 1000 | Number of log lines to keep in buffer |
|
|
33
|
+
|
|
34
|
+
All options can also be set via environment variables with `TEEMUX_` prefix:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
TEEMUX_PORT=9000 teemux -- node app.js
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Viewing Logs
|
|
41
|
+
|
|
42
|
+
### Browser
|
|
43
|
+
|
|
44
|
+
Open http://127.0.0.1:8336/ to view aggregated logs with:
|
|
45
|
+
|
|
46
|
+
- Color-coded process names
|
|
47
|
+
- Auto-scroll (sticks to bottom like a terminal)
|
|
48
|
+
- Scroll up to pause, scroll back down to resume
|
|
49
|
+
|
|
50
|
+
### Terminal / curl
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
curl http://127.0.0.1:8336/
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Plain text stream of all logs.
|
|
57
|
+
|
|
58
|
+
### AGENTS.md
|
|
59
|
+
|
|
60
|
+
If you want your coding agent to see the logs, simply add instructions to AGENTS.md to view the logs by running `curl http://127.0.0.1:8336/`. Example:
|
|
61
|
+
|
|
62
|
+
````md
|
|
63
|
+
## Viewing Logs
|
|
64
|
+
|
|
65
|
+
All process logs are aggregated at http://127.0.0.1:8336/
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# View all recent logs
|
|
69
|
+
curl http://127.0.0.1:8336/
|
|
70
|
+
|
|
71
|
+
# View logs from a specific process
|
|
72
|
+
curl "http://127.0.0.1:8336/?include=[api]"
|
|
73
|
+
|
|
74
|
+
# View only errors (using wildcard for case variations)
|
|
75
|
+
curl "http://127.0.0.1:8336/?include=*error*,*Error*,*ERROR*"
|
|
76
|
+
|
|
77
|
+
# View logs from api OR worker
|
|
78
|
+
curl "http://127.0.0.1:8336/?include=[api],[worker]"
|
|
79
|
+
|
|
80
|
+
# Exclude noisy logs (using wildcard)
|
|
81
|
+
curl "http://127.0.0.1:8336/?exclude=health*,DEBUG"
|
|
82
|
+
```
|
|
83
|
+
````
|
|
84
|
+
|
|
85
|
+
### Filtering Logs
|
|
86
|
+
|
|
87
|
+
Use query parameters to filter logs:
|
|
88
|
+
|
|
89
|
+
| Parameter | Logic | Description |
|
|
90
|
+
|-----------|-------|-------------|
|
|
91
|
+
| `include` | OR | Show lines matching **any** of the patterns |
|
|
92
|
+
| `exclude` | OR | Hide lines matching **any** of the patterns |
|
|
93
|
+
|
|
94
|
+
Patterns support `*` as a wildcard (matches any characters):
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# Show only logs from the api process
|
|
98
|
+
curl "http://127.0.0.1:8336/?include=[api]"
|
|
99
|
+
|
|
100
|
+
# Show only error logs (using wildcard)
|
|
101
|
+
curl "http://127.0.0.1:8336/?include=*error*"
|
|
102
|
+
|
|
103
|
+
# Show logs from api OR worker
|
|
104
|
+
curl "http://127.0.0.1:8336/?include=[api],[worker]"
|
|
105
|
+
|
|
106
|
+
# Hide healthcheck and ping logs
|
|
107
|
+
curl "http://127.0.0.1:8336/?exclude=health*,ping"
|
|
108
|
+
|
|
109
|
+
# Show GET requests to /api endpoints
|
|
110
|
+
curl "http://127.0.0.1:8336/?include=*GET*/api*"
|
|
111
|
+
|
|
112
|
+
# Show api logs but exclude verbose debug output
|
|
113
|
+
curl "http://127.0.0.1:8336/?include=[api]&exclude=DEBUG,TRACE"
|
|
114
|
+
|
|
115
|
+
# In browser
|
|
116
|
+
open "http://127.0.0.1:8336/?include=[api]&exclude=health*"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Filters apply to both buffered logs and new incoming logs in real-time.
|
|
120
|
+
|
|
121
|
+
## Output Example
|
|
122
|
+
|
|
123
|
+
**Terminal (where teemux runs):**
|
|
124
|
+
```
|
|
125
|
+
● started (pid 12345)
|
|
126
|
+
Server listening on :3000
|
|
127
|
+
Processing jobs...
|
|
128
|
+
GET /health 200
|
|
129
|
+
○ exited (code 0)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Browser / curl (aggregated with prefixes):**
|
|
133
|
+
```
|
|
134
|
+
[api] ● started (pid 12345)
|
|
135
|
+
[api] Server listening on :3000
|
|
136
|
+
[worker] Processing jobs...
|
|
137
|
+
[api] GET /health 200
|
|
138
|
+
[worker] ○ exited (code 0)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## FAQ
|
|
142
|
+
|
|
143
|
+
### Docker output appears corrupted with strange spacing
|
|
144
|
+
|
|
145
|
+
When running Docker with the `-t` flag, output may appear corrupted:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
Initializing database...
|
|
149
|
+
The files belonging to this database system...
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Cause:** The `-t` flag allocates a pseudo-TTY, which adds terminal control sequences (cursor positioning, colors, etc.) to the output. These sequences are meant for interactive terminal use, not for piping.
|
|
153
|
+
|
|
154
|
+
**Solution:** Remove the `-t` flag when running through teemux:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# ❌ Don't use -t
|
|
158
|
+
teemux --name db -- docker run --rm -it my-database
|
|
159
|
+
|
|
160
|
+
# ✅ Use -i only (or neither flag)
|
|
161
|
+
teemux --name db -- docker run --rm -i my-database
|
|
162
|
+
teemux --name db -- docker run --rm my-database
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The flags:
|
|
166
|
+
- `-i` = keep stdin open (for interactive input) ✅
|
|
167
|
+
- `-t` = allocate pseudo-TTY (adds terminal formatting) ❌
|
package/dist/teemux.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|