Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking browser console logs? #330

Closed
Bolado opened this issue Jan 1, 2021 · 1 comment
Closed

Checking browser console logs? #330

Bolado opened this issue Jan 1, 2021 · 1 comment
Labels
question Questions related to rod

Comments

@Bolado
Copy link

Bolado commented Jan 1, 2021

Rod Version: v0.85.8

The code to demonstrate your question

if (console.everything === undefined)
{
    console.everything = [];

    console.defaultLog = console.log.bind(console);
    console.log = function(){
        console.everything.push({"type":"log", "datetime":Date().toLocaleString(), "value":Array.from(arguments)});
        console.defaultLog.apply(console, arguments);
    }
    console.defaultError = console.error.bind(console);
    console.error = function(){
        console.everything.push({"type":"error", "datetime":Date().toLocaleString(), "value":Array.from(arguments)});
        console.defaultError.apply(console, arguments);
    }
    console.defaultWarn = console.warn.bind(console);
    console.warn = function(){
        console.everything.push({"type":"warn", "datetime":Date().toLocaleString(), "value":Array.from(arguments)});
        console.defaultWarn.apply(console, arguments);
    }
    console.defaultDebug = console.debug.bind(console);
    console.debug = function(){
        console.everything.push({"type":"debug", "datetime":Date().toLocaleString(), "value":Array.from(arguments)});
        console.defaultDebug.apply(console, arguments);
    }
}

Is there something already built to check what's have been logged in the browser console? Would be very useful to check if for example, the website application have thrown HTTP errors during execution, or something like it.

@Bolado Bolado added the question Questions related to rod label Jan 1, 2021
@ysmood
Copy link
Member

ysmood commented Jan 1, 2021

rod/examples_test.go

Lines 408 to 413 in fd43852

// Listen for all events of console output. You can even listen to multiple types of events at that same time,
// check the doc of EachEvent for details.
go page.EachEvent(func(e *proto.RuntimeConsoleAPICalled) {
fmt.Println(page.MustObjectsToJSON(e.Args))
close(done)
})()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions related to rod
Projects
None yet
Development

No branches or pull requests

2 participants