@@ -20,71 +20,76 @@ let prevError;
20
20
let prevGroup ;
21
21
let prevGroupCollapsed ;
22
22
let prevGroupEnd ;
23
+ let enableDoubleLogging = global . __REACT_DEVTOOLS_ENABLE_DOUBLE_LOGGING__ ;
23
24
24
25
function disabledLog ( ) { }
25
26
disabledLog . __reactDisabledLog = true ;
26
27
27
28
export function disableLogs ( ) : void {
28
29
if ( __DEV__ ) {
29
- if ( disabledDepth === 0 ) {
30
- /* eslint-disable react-internal/no-production-logging */
31
- prevLog = console . log ;
32
- prevInfo = console . info ;
33
- prevWarn = console . warn ;
34
- prevError = console . error ;
35
- prevGroup = console . group ;
36
- prevGroupCollapsed = console . groupCollapsed ;
37
- prevGroupEnd = console . groupEnd ;
38
- // https://github.com/facebook/react/issues/19099
39
- const props = {
40
- configurable : true ,
41
- enumerable : true ,
42
- value : disabledLog ,
43
- writable : true ,
44
- } ;
45
- // $FlowFixMe Flow thinks console is immutable.
46
- Object . defineProperties ( console , {
47
- info : props ,
48
- log : props ,
49
- warn : props ,
50
- error : props ,
51
- group : props ,
52
- groupCollapsed : props ,
53
- groupEnd : props ,
54
- } ) ;
55
- /* eslint-enable react-internal/no-production-logging */
30
+ if ( ! enableDoubleLogging ) {
31
+ if ( disabledDepth === 0 ) {
32
+ /* eslint-disable react-internal/no-production-logging */
33
+ prevLog = console . log ;
34
+ prevInfo = console . info ;
35
+ prevWarn = console . warn ;
36
+ prevError = console . error ;
37
+ prevGroup = console . group ;
38
+ prevGroupCollapsed = console . groupCollapsed ;
39
+ prevGroupEnd = console . groupEnd ;
40
+ // https://github.com/facebook/react/issues/19099
41
+ const props = {
42
+ configurable : true ,
43
+ enumerable : true ,
44
+ value : disabledLog ,
45
+ writable : true ,
46
+ } ;
47
+ // $FlowFixMe Flow thinks console is immutable.
48
+ Object . defineProperties ( console , {
49
+ info : props ,
50
+ log : props ,
51
+ warn : props ,
52
+ error : props ,
53
+ group : props ,
54
+ groupCollapsed : props ,
55
+ groupEnd : props ,
56
+ } ) ;
57
+ /* eslint-enable react-internal/no-production-logging */
58
+ }
59
+ disabledDepth ++ ;
56
60
}
57
- disabledDepth ++ ;
58
61
}
59
62
}
60
63
61
64
export function reenableLogs ( ) : void {
62
65
if ( __DEV__ ) {
63
- disabledDepth -- ;
64
- if ( disabledDepth === 0 ) {
65
- /* eslint-disable react-internal/no-production-logging */
66
- const props = {
67
- configurable : true ,
68
- enumerable : true ,
69
- writable : true ,
70
- } ;
71
- // $FlowFixMe Flow thinks console is immutable.
72
- Object . defineProperties ( console , {
73
- log : { ...props , value : prevLog } ,
74
- info : { ...props , value : prevInfo } ,
75
- warn : { ...props , value : prevWarn } ,
76
- error : { ...props , value : prevError } ,
77
- group : { ...props , value : prevGroup } ,
78
- groupCollapsed : { ...props , value : prevGroupCollapsed } ,
79
- groupEnd : { ...props , value : prevGroupEnd } ,
80
- } ) ;
81
- /* eslint-enable react-internal/no-production-logging */
82
- }
83
- if ( disabledDepth < 0 ) {
84
- console . error (
85
- 'disabledDepth fell below zero. ' +
86
- 'This is a bug in React. Please file an issue.' ,
87
- ) ;
66
+ if ( ! enableDoubleLogging ) {
67
+ disabledDepth -- ;
68
+ if ( disabledDepth === 0 ) {
69
+ /* eslint-disable react-internal/no-production-logging */
70
+ const props = {
71
+ configurable : true ,
72
+ enumerable : true ,
73
+ writable : true ,
74
+ } ;
75
+ // $FlowFixMe Flow thinks console is immutable.
76
+ Object . defineProperties ( console , {
77
+ log : { ...props , value : prevLog } ,
78
+ info : { ...props , value : prevInfo } ,
79
+ warn : { ...props , value : prevWarn } ,
80
+ error : { ...props , value : prevError } ,
81
+ group : { ...props , value : prevGroup } ,
82
+ groupCollapsed : { ...props , value : prevGroupCollapsed } ,
83
+ groupEnd : { ...props , value : prevGroupEnd } ,
84
+ } ) ;
85
+ /* eslint-enable react-internal/no-production-logging */
86
+ }
87
+ if ( disabledDepth < 0 ) {
88
+ console . error (
89
+ 'disabledDepth fell below zero. ' +
90
+ 'This is a bug in React. Please file an issue.' ,
91
+ ) ;
92
+ }
88
93
}
89
94
}
90
95
}
0 commit comments