最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is it possible to hide the "BugReporting extraData" in React Native? (Using Expo) - Stack Overflo

programmeradmin2浏览0评论

Every time I open a React Native app with Expo, I get this massive message in the console with meta data about the app, that doesn't actually do much to help me debug. Especially because it's the same info every time, and it shows up every time the app reloads (even with hot or live reloading):

Running application "main"
with appParams: {
    "rootTag": 171,
    "initialProps": {
        "exp": {
            "manifest": {
                "splash": {
                    "backgroundColor": "#1c2d3c"
                },
                "packagerOpts": {
                    "lanType": "ip",
                    "urlRandomness": "e4-nfi",
                    "hostType": "tunnel",
                    "dev": true,
                    "minify": false
                },
                "debuggerHost": "localhost:19001",
                "bundleUrl": "http://localhost:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false&assetPlugin=pathToProjectFiles",
                "facebookAppId": "FBAppIdGoesHere",
                "android": {
                    "splash": {
                        "xxhdpi": "./src/assets/img/splash-android.png",
                        "backgroundColor": "#1c2d3c",
                        "xxxhdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "xhdpi": "./src/assets/img/splash-android.png",
                        "hdpi": "./src/assets/img/splash-android.png",
                        "xxxhdpi": "./src/assets/img/splash-android.png",
                        "resizeMode": "cover",
                        "ldpi": "./src/assets/img/splash-android.png",
                        "xxhdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "ldpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "xhdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "hdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "mdpi": "./src/assets/img/splash-android.png",
                        "mdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png"
                    },
                    "config": {
                        "googleSignIn": {
                            "apiKey": "APIKeyGoesHere",
                            "certificateHash": "HashGoesHere"
                        }
                    },
                    "iconUrl": "http://localhost:19001/assets/./src/assets/img/icon-android.png",
                    "package": "anizationName.apps",
                    "permissions": ["CAMERA", "INTERNET", "LOCATION", "READ_EXTERNAL_STORAGE", "READ_INTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE", ".anddoes.launcher.permission.UPDATE_COUNT", ".android.launcher.permission.INSTALL_SHORTCUT", ".google.android.c2dm.permission.RECEIVE", ".google.android.gms.permission.ACTIVITY_RECOGNITION", ".google.android.providers.gsf.permission.READ_GSERVICES", ".htc.launcher.permission.READ_SETTINGS", ".htc.launcher.permission.UPDATE_SHORTCUT", ".majeur.launcher.permission.UPDATE_BADGE", ".sec.android.provider.badge.permission.READ", ".sec.android.provider.badge.permission.WRITE", ".sonyericsson.home.permission.BROADCAST_BADGE"],
                    "icon": "./src/assets/img/icon-android.png",
                    "versionCode": 10
                },
                "slug": "app-name-goes-here",
                "facebookDisplayName": "NameOfApp",
                "icon": "./src/assets/img/icon-android.png",
                "primaryColor": "#cccccc",
                "isVerified": true,
                "version": "1.1.5",
                "xde": true,
                "name": "NameOfApp",
                "facebookScheme": "SomeFBSchemeCodeGoesHere",
                "iconUrl": "http://localhost:19001/assets/./src/assets/img/icon-android.png",
                "id": "@jhwheeler/name-of-app",
                "hostUri": "localhost:19000",
                "orientation": "portrait",
                "sdkVersion": "27.0.0",
                "env": {},
                "hooks": {
                    "postPublish": [{
                        "config": {
                            "organization": "organizationNameHere",
                            "project": "projectNameHere",
                            "authToken": "authTokenGoesHere"
                        },
                        "file": "sentry-expo/upload-sourcemaps"
                    }]
                },
                "loadedFromCache": false,
                "ios": {
                    "splash": {
                        "resizeMode": "cover",
                        "imageUrl": "http://localhost:19001/assets/./src/assets/img/splash-ios.png",
                        "backgroundColor": "#1c2d3c",
                        "image": "./src/assets/img/splash-ios.png"
                    },
                    "supportsTablet": false,
                    "iconUrl": "http://localhost:19001/assets/./src/assets/img/icon-ios.png",
                    "infoPlist": {
                        "NSLocationAlwaysUsageDescription": "Nice message goes here",
                        "NSLocationWhenInUseUsageDescription": "Nice message goes here"
                    },
                    "bundleIdentifier": "Name.apps",
                    "buildNumber": "1",
                    "icon": "./src/assets/img/icon-ios.png"
                },
                "logUrl": "http://localhost:19000/logs",
                "privacy": "unlisted",
                "mainModuleName": "node_modules/expo/AppEntry",
                "developer": {
                    "projectRoot": "/path/to/project",
                    "tool": "xde"
                },
                "description": "descriptionOfApp"
            },
            "appOwnership": "expo",
            "initialUri": "exp://localhost:19000",
            "shell": 0
        }
    }
}.__DEV__ === true, development - level warning are ON, performance optimizations are OFF

If I'm looking at the Expo console, it is prefaced with BugReporting extraData: and wraps the above in a JS object. I don't know if this is unique to Expo or a React Native message, but either way:

Is there any way to get rid of this message? It's so large that it makes finding actual errors much more laborious.

Every time I open a React Native app with Expo, I get this massive message in the console with meta data about the app, that doesn't actually do much to help me debug. Especially because it's the same info every time, and it shows up every time the app reloads (even with hot or live reloading):

Running application "main"
with appParams: {
    "rootTag": 171,
    "initialProps": {
        "exp": {
            "manifest": {
                "splash": {
                    "backgroundColor": "#1c2d3c"
                },
                "packagerOpts": {
                    "lanType": "ip",
                    "urlRandomness": "e4-nfi",
                    "hostType": "tunnel",
                    "dev": true,
                    "minify": false
                },
                "debuggerHost": "localhost:19001",
                "bundleUrl": "http://localhost:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false&assetPlugin=pathToProjectFiles",
                "facebookAppId": "FBAppIdGoesHere",
                "android": {
                    "splash": {
                        "xxhdpi": "./src/assets/img/splash-android.png",
                        "backgroundColor": "#1c2d3c",
                        "xxxhdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "xhdpi": "./src/assets/img/splash-android.png",
                        "hdpi": "./src/assets/img/splash-android.png",
                        "xxxhdpi": "./src/assets/img/splash-android.png",
                        "resizeMode": "cover",
                        "ldpi": "./src/assets/img/splash-android.png",
                        "xxhdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "ldpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "xhdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "hdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png",
                        "mdpi": "./src/assets/img/splash-android.png",
                        "mdpiUrl": "http://localhost:19001/assets/./src/assets/img/splash-android.png"
                    },
                    "config": {
                        "googleSignIn": {
                            "apiKey": "APIKeyGoesHere",
                            "certificateHash": "HashGoesHere"
                        }
                    },
                    "iconUrl": "http://localhost:19001/assets/./src/assets/img/icon-android.png",
                    "package": "anizationName.apps",
                    "permissions": ["CAMERA", "INTERNET", "LOCATION", "READ_EXTERNAL_STORAGE", "READ_INTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE", ".anddoes.launcher.permission.UPDATE_COUNT", ".android.launcher.permission.INSTALL_SHORTCUT", ".google.android.c2dm.permission.RECEIVE", ".google.android.gms.permission.ACTIVITY_RECOGNITION", ".google.android.providers.gsf.permission.READ_GSERVICES", ".htc.launcher.permission.READ_SETTINGS", ".htc.launcher.permission.UPDATE_SHORTCUT", ".majeur.launcher.permission.UPDATE_BADGE", ".sec.android.provider.badge.permission.READ", ".sec.android.provider.badge.permission.WRITE", ".sonyericsson.home.permission.BROADCAST_BADGE"],
                    "icon": "./src/assets/img/icon-android.png",
                    "versionCode": 10
                },
                "slug": "app-name-goes-here",
                "facebookDisplayName": "NameOfApp",
                "icon": "./src/assets/img/icon-android.png",
                "primaryColor": "#cccccc",
                "isVerified": true,
                "version": "1.1.5",
                "xde": true,
                "name": "NameOfApp",
                "facebookScheme": "SomeFBSchemeCodeGoesHere",
                "iconUrl": "http://localhost:19001/assets/./src/assets/img/icon-android.png",
                "id": "@jhwheeler/name-of-app",
                "hostUri": "localhost:19000",
                "orientation": "portrait",
                "sdkVersion": "27.0.0",
                "env": {},
                "hooks": {
                    "postPublish": [{
                        "config": {
                            "organization": "organizationNameHere",
                            "project": "projectNameHere",
                            "authToken": "authTokenGoesHere"
                        },
                        "file": "sentry-expo/upload-sourcemaps"
                    }]
                },
                "loadedFromCache": false,
                "ios": {
                    "splash": {
                        "resizeMode": "cover",
                        "imageUrl": "http://localhost:19001/assets/./src/assets/img/splash-ios.png",
                        "backgroundColor": "#1c2d3c",
                        "image": "./src/assets/img/splash-ios.png"
                    },
                    "supportsTablet": false,
                    "iconUrl": "http://localhost:19001/assets/./src/assets/img/icon-ios.png",
                    "infoPlist": {
                        "NSLocationAlwaysUsageDescription": "Nice message goes here",
                        "NSLocationWhenInUseUsageDescription": "Nice message goes here"
                    },
                    "bundleIdentifier": "Name.apps",
                    "buildNumber": "1",
                    "icon": "./src/assets/img/icon-ios.png"
                },
                "logUrl": "http://localhost:19000/logs",
                "privacy": "unlisted",
                "mainModuleName": "node_modules/expo/AppEntry",
                "developer": {
                    "projectRoot": "/path/to/project",
                    "tool": "xde"
                },
                "description": "descriptionOfApp"
            },
            "appOwnership": "expo",
            "initialUri": "exp://localhost:19000",
            "shell": 0
        }
    }
}.__DEV__ === true, development - level warning are ON, performance optimizations are OFF

If I'm looking at the Expo console, it is prefaced with BugReporting extraData: and wraps the above in a JS object. I don't know if this is unique to Expo or a React Native message, but either way:

Is there any way to get rid of this message? It's so large that it makes finding actual errors much more laborious.

Share Improve this question asked Jul 26, 2018 at 13:46 Jackson Holiday WheelerJackson Holiday Wheeler 77112 silver badges26 bronze badges 2
  • 1 did you found any workaround on this one ? :p – Greco Jonathan Commented May 24, 2019 at 8:33
  • Unfortunately, no! I suppose it would be possible to write a script to hide this, but I haven’t taken the time. And Expo have not provided any answer on their forums. – Jackson Holiday Wheeler Commented May 25, 2019 at 10:46
Add a ment  | 

2 Answers 2

Reset to default 2

I solved a similar problem by adding to the project root:

const ignoreConsoleMessages = [
  'Running "main" with'
]
const origLog = console.log
console.log = (...params) => (
  typeof params[0] === 'string' &&
  ignoreConsoleMessages.reduce((acc, i) => acc + ~params[0].indexOf(i), 0)
    ? null
    : origLog(...params)
)

I'm not familiar with Expo, but I encountered this log message recently with a vanilla RN project. I was able to remove it by adding the following to my index file:

   console.ignoredYellowBox = ['react-native BugReporting extraData:'];

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论