Skip to content

Commit f858250

Browse files
committed
docs update
1 parent 3650dc8 commit f858250

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

README.md

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# devlog
22

3-
A lightweight, embeddable development dashboard for Go applications. Monitor logs, HTTP requests, and SQL queries all in one place with minimal setup.
3+
A lightweight, embeddable development dashboard for Go applications. Monitor logs, HTTP requests (client and server), and SQL queries all in one place with minimal setup.
44

55
![Screenshot of devlog dashboard](docs/screenshot.png)
66

@@ -9,12 +9,16 @@ A lightweight, embeddable development dashboard for Go applications. Monitor log
99
- **Logs**: Capture and browse structured logs with filtering and detail view
1010
- **HTTP Client**: Monitor outgoing HTTP requests with timing, headers, and response info
1111
- **HTTP Server**: Track incoming HTTP requests to your application
12-
- **SQL**: Record database queries with timing and parameter information
13-
- **Low Overhead**: Designed to be lightweight enough for production use
12+
- **Low Overhead**: Designed to be lightweight to run in development and testing setups
1413
- **Easy to Integrate**: Embeds into your application with minimal configuration
15-
- **Auto-refresh**: All panels auto-refresh to show the latest data
14+
- **Realtime**: See events as they occur
1615
- **Clean UI**: Modern, minimalist interface with responsive design
1716

17+
## Note
18+
19+
Make sure to not activate `devlog` in production systems! It can expose sensible data like API tokens and other secret data in requests and responses.
20+
We currently do not have any protection of the dashboard handler routes in place.
21+
1822
## Installation
1923

2024
```bash
@@ -50,7 +54,10 @@ func main() {
5054

5155
// 3. Create a mux and mount the dashboard
5256
mux := http.NewServeMux()
53-
mux.Handle("/_devlog/", dlog.DashboardHandler())
57+
58+
// Mount under path prefix /_devlog, so we handle the dashboard handler under this path
59+
// Strip the prefix, so dashboard routes match and inform it about the path prefix to render correct URLs
60+
mux.Handle("/_devlog/", http.StripPrefix("/_devlog", dlog.DashboardHandler("/_devlog")))
5461

5562
// 4. Add your application routes
5663
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
@@ -87,7 +94,7 @@ devlog integrates with Go's `slog` package:
8794
dlog := devlog.New()
8895

8996
logger := slog.New(
90-
dlog.CollectSlogLogs(devlog.CollectSlogLogsOptions{
97+
dlog.CollectSlogLogs(collector.CollectSlogLogsOptions{
9198
Level: slog.LevelDebug, // Capture logs at debug level and above
9299
}),
93100
)
@@ -109,14 +116,13 @@ Wrap your HTTP clients to capture outgoing requests:
109116

110117
```go
111118
// Wrap an existing client
112-
client := &http.Client{Timeout: 10 * time.Second}
113-
wrappedClient := dashboard.WrapHTTPClient(client)
114-
115-
// Or wrap the default client
116-
wrappedClient := dashboard.WrapHTTPClient(nil)
119+
client := &http.Client{
120+
Transport: dlog.CollectHTTPClient(http.DefaultTransport),
121+
Timeout: 10 * time.Second,
122+
}
117123

118124
// Now use the wrapped client
119-
resp, err := wrappedClient.Get("https://example.com")
125+
resp, err := client.Get("https://example.com")
120126
```
121127

122128
### Capturing Incoming HTTP Requests
@@ -128,34 +134,22 @@ mux := http.NewServeMux()
128134
// Add your routes to mux...
129135

130136
// Wrap the handler
131-
handler := dashboard.WrapHTTPHandler(mux)
137+
handler := dlog.CollectHTTPServer(mux)
132138

133139
// Use the wrapped handler
134140
http.ListenAndServe(":8080", handler)
135141
```
136142

137143
### Capturing SQL Queries
138144

139-
Wrap your database connections to capture SQL queries:
140-
141-
```go
142-
// Wrap a database connection
143-
db, err := dashboard.WrapDB("sqlite3", ":memory:")
144-
if err != nil {
145-
// Handle error
146-
}
147-
148-
// Now use the db as normal
149-
_, err = db.Exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)")
150-
```
145+
> Work in progress.
151146
152147
### Configuring the Dashboard
153148

154149
Use options to customize the dashboard:
155150

156151
```go
157152
dashboard := devlog.NewWithOptions(devlog.Options{
158-
BasePath: "/_devlog", // URL path for the dashboard
159153
LogCapacity: 1000, // Maximum number of log entries to keep
160154
HTTPClientCapacity: 100, // Maximum number of HTTP client requests to keep
161155
HTTPServerCapacity: 100, // Maximum number of HTTP server requests to keep
@@ -165,7 +159,7 @@ dashboard := devlog.NewWithOptions(devlog.Options{
165159

166160
## TODOs
167161

168-
- [x] Use events to unify collected data in a combined view with grouping
162+
- [ ] Implement filtering of events
169163

170164
## License
171165

docs/screenshot.png

434 KB
Loading

0 commit comments

Comments
 (0)