From 1263b48dc88da0a2a9c07a0b38d24d3f1e71b36c Mon Sep 17 00:00:00 2001 From: hupe1980 Date: Tue, 9 Jul 2024 07:04:34 +0200 Subject: [PATCH] Add bidi log --- README.md | 2 +- bidi/log.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b5d755a..f7a3444 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ if err != nil { ## Subscribe ```go -biDiSession.OnLogEntry(&bidi.OnLogEntryHandler{ +biDiSession.OnLogEntryAdded(&bidi.OnLogEntryHandler{ LogTypeConsoleHandlerFunc: func(entry *bidi.ConsoleLogEntry) error { fmt.Println(entry) return nil diff --git a/bidi/log.go b/bidi/log.go index b427827..7c1e374 100644 --- a/bidi/log.go +++ b/bidi/log.go @@ -52,7 +52,7 @@ type OnLogEntryHandler struct { LogTypeJavascriptHandlerFunc func(entry *JavascriptLogEntry) error } -func (s *Session) OnLogEntry(handler *OnLogEntryHandler) { +func (s *Session) OnLogEntryAdded(handler *OnLogEntryHandler) { s.client.CallbackEvent("log.entryAdded", func(params json.RawMessage) error { type entry struct { Type LogType `json:"type"` @@ -70,6 +70,7 @@ func (s *Session) OnLogEntry(handler *OnLogEntryHandler) { if err := json.Unmarshal(params, &e); err != nil { return err } + return handler.LogTypeTextHandlerFunc(e) } case LogTypeConsole: @@ -78,6 +79,7 @@ func (s *Session) OnLogEntry(handler *OnLogEntryHandler) { if err := json.Unmarshal(params, &e); err != nil { return err } + return handler.LogTypeConsoleHandlerFunc(e) } case LogTypeJavascript: @@ -86,6 +88,7 @@ func (s *Session) OnLogEntry(handler *OnLogEntryHandler) { if err := json.Unmarshal(params, &e); err != nil { return err } + return handler.LogTypeJavascriptHandlerFunc(e) } }