Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Reduce logging noise produced by the browser module as a default #1553

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 15 additions & 31 deletions common/frame_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,11 @@ func (fs *FrameSession) onConsoleAPICalled(event *cdpruntime.EventConsoleAPICall
WithField("source", "browser").
WithField("browser_source", "console-api")

/* accessing the state Group while not on the eventloop is racy
if s := fs.vu.State(); s.Group.Path != "" {
l = l.WithField("group", s.Group.Path)
}
*/
/* accessing the state Group while not on the eventloop is racy
if s := fs.vu.State(); s.Group.Path != "" {
l = l.WithField("group", s.Group.Path)
}
*/

parsedObjects := make([]string, 0, len(event.Args))
for _, robj := range event.Args {
Expand All @@ -661,18 +661,9 @@ func (fs *FrameSession) onConsoleAPICalled(event *cdpruntime.EventConsoleAPICall

msg := strings.Join(parsedObjects, " ")

switch event.Type {
case "log", "info":
l.Info(msg)
case "warning":
l.Warn(msg)
case "error":
l.Error(msg)
default:
// this is where debug & other console.* apis will default to (such as
// console.table).
l.Debug(msg)
}
// this is where debug & other console.* apis will default to (such as
oleiade marked this conversation as resolved.
Show resolved Hide resolved
// console.table).
l.Debug(msg)
}

func (fs *FrameSession) onExceptionThrown(event *cdpruntime.EventExceptionThrown) {
Expand Down Expand Up @@ -894,21 +885,14 @@ func (fs *FrameSession) onLogEntryAdded(event *cdplog.EventEntryAdded) {
WithField("url", event.Entry.URL).
WithField("browser_source", event.Entry.Source.String()).
WithField("line_number", event.Entry.LineNumber)
/* accessing the state Group while not on the eventloop is racy
if s := fs.vu.State(); s.Group.Path != "" {
l = l.WithField("group", s.Group.Path)
}
*/
switch event.Entry.Level {
case "info":
l.Info(event.Entry.Text)
case "warning":
l.Warn(event.Entry.Text)
case "error":
l.WithField("stacktrace", event.Entry.StackTrace).Error(event.Entry.Text)
default:
l.Debug(event.Entry.Text)

/* accessing the state Group while not on the eventloop is racy
if s := fs.vu.State(); s.Group.Path != "" {
l = l.WithField("group", s.Group.Path)
}
*/

l.Debug(event.Entry.Text)
}

func (fs *FrameSession) onPageLifecycle(event *cdppage.EventLifecycleEvent) {
Expand Down
4 changes: 2 additions & 2 deletions common/remote_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func valueFromRemoteObject(_ context.Context, robj *cdpruntime.RemoteObject) (an
func parseConsoleRemoteObjectPreview(logger *log.Logger, op *cdpruntime.ObjectPreview) (string, error) {
obj := make(map[string]string)
if op.Overflow {
logger.Infof("parseConsoleRemoteObjectPreview", "object is too large and will be parsed partially")
logger.Debugf("parseConsoleRemoteObjectPreview", "object is too large and will be parsed partially")
}

for _, p := range op.Properties {
Expand All @@ -209,7 +209,7 @@ func parseConsoleRemoteObjectPreview(logger *log.Logger, op *cdpruntime.ObjectPr
func parseConsoleRemoteArrayPreview(logger *log.Logger, op *cdpruntime.ObjectPreview) (string, error) {
arr := make([]any, 0, len(op.Properties))
if op.Overflow {
logger.Infof("parseConsoleRemoteArrayPreview", "array is too large and will be parsed partially")
logger.Debugf("parseConsoleRemoteArrayPreview", "array is too large and will be parsed partially")
}

for _, p := range op.Properties {
Expand Down
Loading