@@ -3,7 +3,11 @@ import parseErrorStack from 'react-native/Libraries/Core/Devtools/parseErrorStac
33
44type ConsoleLogFunction = ( ...args : unknown [ ] ) => void ;
55
6- export const installConsoleSymbolicator = ( ) => {
6+ export const installConsoleSymbolicator = ( {
7+ excludeReactNativeCoreFrames = false ,
8+ } : {
9+ excludeReactNativeCoreFrames ?: boolean ;
10+ } = { } ) => {
711 if ( ! __DEV__ ) {
812 return ;
913 }
@@ -18,7 +22,10 @@ export const installConsoleSymbolicator = () => {
1822 } ;
1923
2024 const makeSymbolicatedConsole = ( fn : ConsoleLogFunction ) =>
21- symbolicatedConsole ( fn , originalConsole . error ) ;
25+ symbolicatedConsole ( fn , {
26+ logError : originalConsole . error ,
27+ excludeReactNativeCoreFrames,
28+ } ) ;
2229
2330 console . error = makeSymbolicatedConsole ( originalConsole . error ) ;
2431 console . warn = makeSymbolicatedConsole ( originalConsole . warn ) ;
@@ -31,7 +38,16 @@ export const installConsoleSymbolicator = () => {
3138} ;
3239
3340const symbolicatedConsole =
34- ( original : ConsoleLogFunction , logError : ConsoleLogFunction ) =>
41+ (
42+ original : ConsoleLogFunction ,
43+ {
44+ logError,
45+ excludeReactNativeCoreFrames,
46+ } : {
47+ logError : ConsoleLogFunction ;
48+ excludeReactNativeCoreFrames : boolean ;
49+ }
50+ ) =>
3551 async ( ...args : unknown [ ] ) => {
3652 const symbolicating : Array < Promise < unknown > > = args . map ( async ( arg ) => {
3753 if ( ! ( arg instanceof Error ) || ! arg . stack ) {
@@ -66,6 +82,11 @@ const symbolicatedConsole =
6682 return ` at ${ frame . methodName } (${ fileInfo } )` ;
6783 }
6884 )
85+ . filter (
86+ ( line : string ) =>
87+ ! excludeReactNativeCoreFrames ||
88+ ! line . includes ( 'node_modules/react-native' )
89+ )
6990 . join ( '\n' ) ;
7091
7192 arg . stack = arg . message ? `${ arg . message } \n${ newStack } ` : newStack ;
0 commit comments