Skip to content

Commit a12314e

Browse files
committed
docs: Improve documentation for getting started
1 parent 31b6453 commit a12314e

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

docs/Getting-started.md

+22-5
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,26 @@ corresponds to the `class` content attribute is not called `class` but `classNam
210210
211211
## Logging
212212
213-
You can inject an `log/slog.Logger` calling `SetDefaultLogger` in
214-
the `browser/logger` package.
213+
By default, Gost does not write to stdout. You can inject a global logger
214+
`*log/slog.Logger` calling `SetDefaultLogger` in the `browser/logger` package.
215215
216-
This works on a global scale. A future enhancement might be to allow injecting
217-
the logger into a browser, allowing tests more control of log output on a
218-
test-by-test case.
216+
Each browser also supports you to inject a browser scoped logger.
217+
218+
```
219+
browser := browser.New(
220+
browser.WithLogger(logger), // *slog.Logger instance
221+
browser.WithHandler(rootHTTPHandler),
222+
)
223+
win, _ := browser.Open(url)
224+
```
225+
226+
### Log levels and verbosity
227+
228+
There isn't a concrete logging strategy, except all error cases should be
229+
logged.
230+
231+
- Most JavaScript API calls will log a debug statement.
232+
- Some internal Go calls will log at the debug level.
233+
- Some high level functions log at info level, e.g., `Window.Navigate`.
234+
- `console` functions will log with the appropriate level.
235+
- Errors, including unhandled JavaScript errors will generate error logs

html/window.go

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type Clock interface {
2828

2929
// Describes a current browser context
3030
type BrowsingContext interface {
31+
// Logger returns the currently configured logger for the window. Returns
32+
// nil if no instance is created.
3133
Logger() *slog.Logger
3234
HTTPClient() http.Client
3335
LocationHREF() string

0 commit comments

Comments
 (0)