-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
COMMUNITY: good first issueGood for newcomersGood for newcomersCOMMUNITY: PR is welcomedWe think it's a good feature to have but would love for the community to help with the PR for itWe think it's a good feature to have but would love for the community to help with the PR for itCOMP: DXDeveloper Experience related issueDeveloper Experience related issueCOMP: docsImprovements or additions to documentationImprovements or additions to documentationSTATUS-2: waiting for community PR
Description
Suggestion
Using console.log
seems to be common. Yet it has a downside. Sometimes it's left unintentionally in the code.
When the codebase becomes bigger, then a terminal is littered with logs, but the file and line of code that made that log are not apparent.
One technique that we use is to override console.log
to include the stack trace too:
const originalLog = console.log
console.log = props => {
const stack = new Error()
.stack
.split("\n")
.filter(i => !/^.*(\.vite|keycloak|\.main\.jsx).*/.test(i))
originalLog(stack, props)
}
Try console.log("something")
and you will see a good stack helping you find the place of the left log.
This works when we put it inside a component. But when we want to put it inside the entry.express
or entry.dev
or entry.preview
, then it has no effect.
Please add a section to the documentation explaining your official way of finding useless console.log
statements.
dko1905
Metadata
Metadata
Assignees
Labels
COMMUNITY: good first issueGood for newcomersGood for newcomersCOMMUNITY: PR is welcomedWe think it's a good feature to have but would love for the community to help with the PR for itWe think it's a good feature to have but would love for the community to help with the PR for itCOMP: DXDeveloper Experience related issueDeveloper Experience related issueCOMP: docsImprovements or additions to documentationImprovements or additions to documentationSTATUS-2: waiting for community PR