@@ -15,15 +15,8 @@ import {format} from './utils';
1515import { getInternalReactConstants } from './renderer' ;
1616import { getStackByFiberInDevAndProd } from './DevToolsFiberComponentStack' ;
1717
18- // NOTE: KEEP IN SYNC with src/hook.js
1918const OVERRIDE_CONSOLE_METHODS = [ 'error' , 'trace' , 'warn' , 'log' ] ;
2019const DIMMED_NODE_CONSOLE_COLOR = '\x1b[2m%s\x1b[0m' ;
21- const DARK_MODE_DIMMED_WARNING_COLOR = 'rgba(250, 180, 50, 0.5)' ;
22- const DARK_MODE_DIMMED_ERROR_COLOR = 'rgba(250, 123, 130, 0.5)' ;
23- const DARK_MODE_DIMMED_LOG_COLOR = 'rgba(125, 125, 125, 0.5)' ;
24- const LIGHT_MODE_DIMMED_WARNING_COLOR = 'rgba(250, 180, 50, 0.75)' ;
25- const LIGHT_MODE_DIMMED_ERROR_COLOR = 'rgba(250, 123, 130, 0.75)' ;
26- const LIGHT_MODE_DIMMED_LOG_COLOR = 'rgba(125, 125, 125, 0.75)' ;
2720
2821// React's custom built component stack strings match "\s{4}in"
2922// Chrome's prefix matches "\s{4}at"
@@ -256,25 +249,29 @@ export function patch({
256249 case 'warn' :
257250 color =
258251 browserTheme === 'light'
259- ? LIGHT_MODE_DIMMED_WARNING_COLOR
260- : DARK_MODE_DIMMED_WARNING_COLOR ;
252+ ? process . env . LIGHT_MODE_DIMMED_WARNING_COLOR
253+ : process . env . DARK_MODE_DIMMED_WARNING_COLOR ;
261254 break ;
262255 case 'error' :
263256 color =
264257 browserTheme === 'light'
265- ? LIGHT_MODE_DIMMED_ERROR_COLOR
266- : DARK_MODE_DIMMED_ERROR_COLOR ;
258+ ? process . env . LIGHT_MODE_DIMMED_ERROR_COLOR
259+ : process . env . DARK_MODE_DIMMED_ERROR_COLOR ;
267260 break ;
268261 case 'log' :
269262 default :
270263 color =
271264 browserTheme === 'light'
272- ? LIGHT_MODE_DIMMED_LOG_COLOR
273- : DARK_MODE_DIMMED_LOG_COLOR ;
265+ ? process . env . LIGHT_MODE_DIMMED_LOG_COLOR
266+ : process . env . DARK_MODE_DIMMED_LOG_COLOR ;
274267 break ;
275268 }
276269
277- originalMethod ( `%c${ format ( ...args ) } ` , `color: ${ color } ` ) ;
270+ if ( color ) {
271+ originalMethod ( `%c${ format ( ...args ) } ` , `color: ${ color } ` ) ;
272+ } else {
273+ throw Error ( 'Console color is not defined' ) ;
274+ }
278275 }
279276 }
280277 } else {
0 commit comments