File tree 2 files changed +24
-5
lines changed
2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -210,9 +210,26 @@ corresponds to the `class` content attribute is not called `class` but `classNam
210
210
211
211
## Logging
212
212
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.
215
215
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
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ type Clock interface {
28
28
29
29
// Describes a current browser context
30
30
type BrowsingContext interface {
31
+ // Logger returns the currently configured logger for the window. Returns
32
+ // nil if no instance is created.
31
33
Logger () * slog.Logger
32
34
HTTPClient () http.Client
33
35
LocationHREF () string
You can’t perform that action at this time.
0 commit comments