tinylogs 0.1.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 +21 -0
- package/README.md +103 -0
- package/dist/cli.js +635 -0
- package/dist/cli.js.map +7 -0
- package/dist/client/index.d.ts +30 -0
- package/dist/client/index.js +65 -0
- package/dist/client/index.js.map +7 -0
- package/dist/server/index.js +480 -0
- package/dist/server/index.js.map +7 -0
- package/dist/src/types.d.ts +17 -0
- package/dist/ui/bundle.css +2 -0
- package/dist/ui/bundle.css.map +7 -0
- package/dist/ui/bundle.js +2 -0
- package/dist/ui/bundle.js.map +7 -0
- package/dist/ui/index.html +13 -0
- package/package.json +82 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nikita Medvedev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# tinylogs
|
|
2
|
+
|
|
3
|
+
A tiny, self-hosted **central log receiver + live dashboard**. Apps push log lines
|
|
4
|
+
over HTTP; you watch them in a fast, dense browser dashboard with label filtering.
|
|
5
|
+
Single Node process, single SQLite file. Runs anywhere `npx` runs.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx tinylogs init # wizard: port, admin user/pass, retention → writes tinylogs.config.json + prints an ingest token
|
|
11
|
+
npx tinylogs start # runs the receiver + dashboard (default http://127.0.0.1:4700)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Open the dashboard, log in with the admin user you created.
|
|
15
|
+
|
|
16
|
+
Non-interactive init (CI/containers):
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
TINYLOGS_PASSWORD=hunter2 npx tinylogs init --yes --port 4700
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Sending logs
|
|
23
|
+
|
|
24
|
+
Anything that can make an HTTP request can send logs. `service` and `message` are
|
|
25
|
+
required; `labels` are arbitrary string key/values. `level` is just a label with
|
|
26
|
+
special coloring.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
curl -XPOST http://localhost:4700/ingest \
|
|
30
|
+
-H "Authorization: Bearer <INGEST_TOKEN>" \
|
|
31
|
+
-H "Content-Type: application/json" \
|
|
32
|
+
-d '{"service":"debtors-bot","message":"reminder sent","labels":{"level":"info","user":"12345"}}'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Batch by sending an array. Response: `{"accepted": N}` (400 if `service`/`message`
|
|
36
|
+
missing, 401 if the token is wrong).
|
|
37
|
+
|
|
38
|
+
### Node client
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { TinyLogsClient } from 'tinylogs/client';
|
|
42
|
+
|
|
43
|
+
const logs = new TinyLogsClient({
|
|
44
|
+
url: 'http://localhost:4700',
|
|
45
|
+
token: process.env.TINYLOGS_TOKEN!,
|
|
46
|
+
service: 'debtors-bot',
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
logs.info('reminder sent', { user: '12345' });
|
|
50
|
+
logs.error('boom', { user: '12345' });
|
|
51
|
+
// fire-and-forget: never throws, never blocks your app, batches automatically.
|
|
52
|
+
await logs.close(); // flush on shutdown
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Configuration
|
|
56
|
+
|
|
57
|
+
`tinylogs.config.json` (created by `init`, in the current directory by default):
|
|
58
|
+
|
|
59
|
+
| Field | Meaning | Default |
|
|
60
|
+
|-------|---------|---------|
|
|
61
|
+
| `port` / `host` | Listen address | `4700` / `127.0.0.1` |
|
|
62
|
+
| `dbPath` | SQLite file (relative to the config file) | `tinylogs.db` |
|
|
63
|
+
| `retentionDays` | Delete logs older than this | `14` |
|
|
64
|
+
| `maxSizeMB` | Cap the DB file; oldest rows pruned first | `500` |
|
|
65
|
+
| `bufferSize` | In-memory live-tail buffer | `2000` |
|
|
66
|
+
| `sessionSecret` / `ingestTokenHash` | Generated at init — do not edit | — |
|
|
67
|
+
|
|
68
|
+
Override the config location with `--config <path>` or `TINYLOGS_CONFIG`.
|
|
69
|
+
Rotate the ingest token with `npx tinylogs rotate-token`.
|
|
70
|
+
|
|
71
|
+
## Security
|
|
72
|
+
|
|
73
|
+
- **No default password** — `init` forces you to set one.
|
|
74
|
+
- **TLS is delegated to a reverse proxy.** tinylogs serves plain HTTP; put nginx or
|
|
75
|
+
Caddy in front for HTTPS. Example (Caddy):
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
logs.example.com {
|
|
79
|
+
reverse_proxy 127.0.0.1:4700
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- Dashboard auth is a signed **httpOnly session cookie**; `/api/*` and `/ws` require it.
|
|
84
|
+
- `/api/login` is rate-limited against brute force.
|
|
85
|
+
- The ingest token is a separate shared secret, stored **hashed**; shown only once.
|
|
86
|
+
|
|
87
|
+
## How it works
|
|
88
|
+
|
|
89
|
+
- **Storage:** SQLite in WAL mode. `logs` holds each line (labels as JSON for one-read
|
|
90
|
+
render); `log_labels` explodes labels for index-backed `key=value` filtering.
|
|
91
|
+
- **Live tail:** a bounded in-memory ring buffer seeds new browser tabs and feeds the
|
|
92
|
+
WebSocket stream. The DB is the source of truth for history + search.
|
|
93
|
+
- **Retention:** a background task prunes by age and by size (whichever hits first) and
|
|
94
|
+
VACUUMs; failures are logged, never fatal.
|
|
95
|
+
|
|
96
|
+
## Non-goals
|
|
97
|
+
|
|
98
|
+
Not a clustered/distributed store, not metrics/tracing, not multi-tenant SaaS. One node,
|
|
99
|
+
one SQLite file, one admin.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT © 2026 Nikita Medvedev
|