Skip to content

Commit

Permalink
Add bidi log
Browse files Browse the repository at this point in the history
  • Loading branch information
hupe1980 committed Jul 9, 2024
1 parent 21c350a commit 1263b48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion bidi/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -86,6 +88,7 @@ func (s *Session) OnLogEntry(handler *OnLogEntryHandler) {
if err := json.Unmarshal(params, &e); err != nil {
return err
}

return handler.LogTypeJavascriptHandlerFunc(e)
}
}
Expand Down

0 comments on commit 1263b48

Please sign in to comment.