[RFC] Refine logging strategy #21979
Labels
discussion
ready to take
Help wanted. Guidance available. There is a high chance the change will be accepted
RFC
Request For Comments
Context
This is a follow-up on #15343. Looking at the components (under
/packages/*)
, we can count the following usage frequency of the different logging methods:console.error
x69console.warn
x25Historically, React used to use console.warn. It was changed in facebook/react#3440 to benefit from the stack trace of error. Something Chrome now supports for warn too:
Problem
It doesn't seem that there is any rule or convention around when to use error over warn. Do we have an improvement opportunity here? Could we use it as leverage to help developers that need to prioritize which problem they should focus on first?
Proposal
What do you think of:
error
overwarn
to be safe.console.error
we use it for cases that are important. It can be a crash of the page, explaining what went wrong, or creating awareness about a significantly wrong user-experience. For instance:material-ui/packages/material-ui/src/FormControl/FormControl.js
Lines 135 to 140 in 56a1141
console.warn
is used as soon as something is not right, leading to incorrect behavior but not critical. For instance, these should be warnings:material-ui/packages/material-ui/src/StepContent/StepContent.js
Lines 44 to 46 in 56a1141
material-ui/packages/material-ui-icons/src/Motorcycle.js
Lines 4 to 8 in 56a1141
material-ui/packages/material-ui/src/Breadcrumbs/Breadcrumbs.js
Lines 81 to 86 in 56a1141
material-ui/packages/material-ui/src/GridList/GridList.js
Lines 46 to 50 in 56a1141
The text was updated successfully, but these errors were encountered: