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

Add line numbers to console log when showing source code #498

Open
fyellin opened this issue Nov 15, 2022 · 0 comments
Open

Add line numbers to console log when showing source code #498

fyellin opened this issue Nov 15, 2022 · 0 comments

Comments

@fyellin
Copy link

fyellin commented Nov 15, 2022

This is a convenience for developers that ought to have no affect on uysers

When there is an error in a shader, the log shows "Error in Line 64" and then a dump of the source code. As a convenience, there should be line numbers in the console log to make it easier to find where the mistake is.

This is a small change to WglShader.js. Patch is already written.

            if (!ignored) {
                console.warn("WebGLShader: gl.getShaderInfoLog() wasn't empty: " + gl.getShaderInfoLog(shader));
                // The error message often includes line numbers, so best if our console log has them.
                let sourceCodeLines = sourceCode.split("\n");
                let annotatedLines = sourceCodeLines.map((element, index) =>
                    `${(index + 1).toString().padStart(3)} ${element}`)
                console.warn("Source code was: \n" + annotatedLines.join("\n"));
            }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant