Skip to content

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

@fyellin

Description

@fyellin

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"));
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions