func (p *Page) ReadNewLogs(logType string) ([]Log, error) {
	if p.logs == nil {
		p.logs = map[string][]Log{}
	}

	clientLogs, err := p.session.NewLogs(logType)
	if err != nil {
		return nil, fmt.Errorf("failed to retrieve logs: %s", err)
	}

	messageMatcher := regexp.MustCompile(`^(?s:(.+))\s\(([^)]*:\w*)\)$`)

	var logs []Log
	for _, clientLog := range clientLogs {
		matches := messageMatcher.FindStringSubmatch(clientLog.Message)
		message, location := clientLog.Message, ""
		if len(matches) > 2 {
			message, location = matches[1], matches[2]
		}

		log := Log{message, location, clientLog.Level, msToTime(clientLog.Timestamp)}
		logs = append(logs, log)
	}
	p.logs[logType] = append(p.logs[logType], logs...)

	return logs, nil
}
func (p *Page) ReadNewLogs(logType string) ([]Log, error) {
	if p.logs == nil {
		p.logs = map[string][]Log{}
	}

	clientLogs, err := p.session.NewLogs(logType)
	if err != nil {
		return nil, fmt.Errorf("failed to retrieve logs: %s", err)
	}

	messageMatcher := regexp.MustCompile(`^(?s:(.+))\s\(([^)]*:\w*)\)$`)

	var logs []Log
	for _, clientLog := range clientLogs {
		matches := messageMatcher.FindStringSubmatch(clientLog.Message)
		message, location := clientLog.Message, ""
		if len(matches) > 2 {
			message, location = matches[1], matches[2]
		}

		log := Log{message, location, clientLog.Level, msToTime(clientLog.Timestamp)}
		logs = append(logs, log)
	}
	p.logs[logType] = append(p.logs[logType], logs...)

	return logs, nil
}
func ( p * Page ) ReadNewLogs ( logType string ) ( [ ] Log , error ) { if p . logs == nil { p . logs = map [ string ] [ ] Log { } } clientLogs , err := p . session . NewLogs ( logType ) if err != nil { return nil , fmt . Errorf ( " " , err ) } messageMatcher := regexp . MustCompile ( `^(?s:(.+))\s\(([^)]*:\w*)\)$` ) var logs [ ] Log for _ , clientLog := range clientLogs { matches := messageMatcher . FindStringSubmatch ( clientLog . Message ) message , location := clientLog . Message , " " if len ( matches ) > 2 { message , location = matches [ 1 ] , matches [ 2 ] } log := Log { message , location , clientLog . Level , msToTime ( clientLog . Timestamp ) } logs = append ( logs , log ) } p . logs [ logType ] = append ( p . logs [ logType ] , logs ... ) return logs , nil }
// ReadNewLogs returns new log messages of the provided log type. For example,
// page.ReadNewLogs("browser") returns browser console logs, such as JavaScript
// logs and errors. Only logs since the last call to ReadNewLogs are returned.
// Valid log types may be obtained using the LogTypes method.
ReadNewLogs returns new log messages of the provided log type . For example page . ReadNewLogs ( browser ) returns browser console logs such as JavaScript logs and errors . Only logs since the last call to ReadNewLogs are returned . Valid log types may be obtained using the LogTypes method .