草庐IT

javascript - 是否可以在 React Native 中隐藏 "BugReporting extraData"? (使用世博会)

coder 2024-05-10 原文

每次我使用 Expo 打开 React Native 应用程序时,我都会在控制台中收到大量消息,其中包含有关该应用程序的元数据,这实际上并不能帮助我进行调试。特别是因为它每次都是相同的信息,并且每次应用程序重新加载时都会显示(即使是热重新加载或实时重新加载):

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": "com.organizationName.apps",
                    "permissions": ["CAMERA", "INTERNET", "LOCATION", "READ_EXTERNAL_STORAGE", "READ_INTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE", "com.anddoes.launcher.permission.UPDATE_COUNT", "com.android.launcher.permission.INSTALL_SHORTCUT", "com.google.android.c2dm.permission.RECEIVE", "com.google.android.gms.permission.ACTIVITY_RECOGNITION", "com.google.android.providers.gsf.permission.READ_GSERVICES", "com.htc.launcher.permission.READ_SETTINGS", "com.htc.launcher.permission.UPDATE_SHORTCUT", "com.majeur.launcher.permission.UPDATE_BADGE", "com.sec.android.provider.badge.permission.READ", "com.sec.android.provider.badge.permission.WRITE", "com.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": "com.orgName.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

如果我正在查看 Expo 控制台,它以 BugReporting extraData: 开头,并将上面的内容包装在一个 JS 对象中。我不知道这是 Expo 独有的还是 React Native 消息,但无论哪种方式:

有什么办法可以去掉这条消息吗?它太大了,使得查找实际错误变得更加费力。

最佳答案

我通过添加到项目根解决了类似的问题:

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)
)

关于javascript - 是否可以在 React Native 中隐藏 "BugReporting extraData"? (使用世博会),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51540414/

有关javascript - 是否可以在 React Native 中隐藏 "BugReporting extraData"? (使用世博会)的更多相关文章

  1. ruby - 为什么我可以在 Ruby 中使用 Object#send 访问私有(private)/ protected 方法? - 2

    类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc

  2. ruby-on-rails - rails : "missing partial" when calling 'render' in RSpec test - 2

    我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou

  3. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  4. ruby-on-rails - 如何验证 update_all 是否实际在 Rails 中更新 - 2

    给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru

  5. ruby - 使用 Vim Rails,您可以创建一个新的迁移文件并一次性打开它吗? - 2

    使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta

  6. ruby - 我可以使用 Ruby 从 CSV 中删除列吗? - 2

    查看Ruby的CSV库的文档,我非常确定这是可能且简单的。我只需要使用Ruby删除CSV文件的前三列,但我没有成功运行它。 最佳答案 csv_table=CSV.read(file_path_in,:headers=>true)csv_table.delete("header_name")csv_table.to_csv#=>ThenewCSVinstringformat检查CSV::Table文档:http://ruby-doc.org/stdlib-1.9.2/libdoc/csv/rdoc/CSV/Table.html

  7. ruby - 检查 "command"的输出应该包含 NilClass 的意外崩溃 - 2

    为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar

  8. ruby - 检查数组是否在增加 - 2

    这个问题在这里已经有了答案:Checktoseeifanarrayisalreadysorted?(8个答案)关闭9年前。我只是想知道是否有办法检查数组是否在增加?这是我的解决方案,但我正在寻找更漂亮的方法:n=-1@arr.flatten.each{|e|returnfalseife

  9. ruby - 我可以使用 aws-sdk-ruby 在 AWS S3 上使用事务性文件删除/上传吗? - 2

    我发现ActiveRecord::Base.transaction在复杂方法中非常有效。我想知道是否可以在如下事务中从AWSS3上传/删除文件:S3Object.transactiondo#writeintofiles#raiseanexceptionend引发异常后,每个操作都应在S3上回滚。S3Object这可能吗?? 最佳答案 虽然S3API具有批量删除功能,但它不支持事务,因为每个删除操作都可以独立于其他操作成功/失败。该API不提供任何批量上传功能(通过PUT或POST),因此每个上传操作都是通过一个独立的API调用完成的

  10. ruby-on-rails - 迷你测试错误 : "NameError: uninitialized constant" - 2

    我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test

随机推荐