Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reduce debug output from CoreData?

I'm working on a iOS/macOS project where I'm using CoreData. It works fine, but it outputs enormous amounts of debugging info to the Console. This makes the Console unusable, since my print statements are buried in all the CoreData related stuff.

I have a pretty simple CoreData setup with fetching of some data, so these are not errors, just general event logs it seems. I have the same results on other projects I have used CoreData.

Any way to reduce/remove this logging to the console?

Some sample data (all data here):

CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _

performExportWithRequest:]_block_invoke_2(946): Finished export: <PFCloudKitExporter: 0x2838bd840>
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _finishedRequest:withResult:](2102): Finished request: <NSCloudKitMirroringExportRequest: 0x2823bbb40> DC26CDEE-0AB6-42CD-81E5-996E7E7727F9 with result: <NSCloudKitMirroringResult: 0x282dfcfa0> success: 1 madeChanges: 0 error: (null)
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _scheduleAutomatedExportWithLabel:activity:completionHandler:]_block_invoke(2170): <NSCloudKitMirroringDelegate: 0x281ae4580> - Finished automatic export - AppActivationExport - with result: <NSCloudKitMirroringResult: 0x282dfcfa0> success: 1 madeChanges: 0 error: (null)
CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate finishedAutomatedRequestWithResult:](2115): Finished request '<NSCloudKitMirroringExportRequest: 0x2823bbb40> DC26CDEE-0AB6-42CD-81E5-996E7E7727F9' with result: <NSCloudKitMirroringResult: 0x282dfcfa0> success: 1 madeChanges: 0 error: (null)
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest](2073): <NSCloudKitMirroringDelegate: 0x281ae4580>: Checking for pending requests.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(2088): <NSCloudKitMirroringDelegate: 0x281ae4580>: No more requests to execute.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _scheduleAutomatedImportWithLabel:activity:completionHandler:](2140): <NSCloudKitMirroringDelegate: 0x281ae4580> - Beginning automated import - ImportActivity - in response to activity:
<CKSchedulerActivity: 0x280ec8f00; additionalXPCActivityCriteria={
    Priority = Utility;
}
like image 489
eivindml Avatar asked Sep 12 '19 11:09

eivindml


3 Answers

Try adding these as launch arguments see if it helps

-com.apple.CoreData.SQLDebug 0
-com.apple.CoreData.Logging.stderr 0               
-com.apple.CoreData.ConcurrencyDebug 0
-com.apple.CoreData.MigrationDebug 0

EDIT1: I found this in Apple docs: Choose Product > Scheme > Edit Scheme. Select an action such as Run, and select the Arguments tab. Pass the com.apple.CoreData.CloudKitDebug user default setting with a debug level value as an argument to the application. Like this

 -com.apple.CoreData.CloudKitDebug 0

Add this last one as a launch argument and you should achieve what you wanted.

link to the AppleDocs Check the section named Debug Errors in Core Data with CloudKit

like image 50
AD Progress Avatar answered Nov 14 '22 01:11

AD Progress


I had the same problem.
This will disable CoreData debug output:
in 'Arguments passed on launch':
-com.apple.CoreData.Logging.stderr 0
Worked for me.

like image 30
nouatzi Avatar answered Nov 14 '22 00:11

nouatzi


Follow these steps in Xcode:

  1. Products
  2. Scheme
  3. Edit scheme...
  4. Chose left side your way of building the app (I guess Run)

I guess you will see -com.apple.CoreData.SQLDebug in 'Arguments passed on launch'. If you see that, turn it off. If you don't see it, add:

-com.apple.CoreData.SQLDebug 1

Values and descriptions:

  1. SQL Statements, Row count and Execution time
  2. Bind values and the truncated version of NSSQLiteStatement that does not list the full list of Managed objects.
  3. List of Managed Objects returned for the query. These objects have not been faulted into memory and therefore only the Managed Object ID is outputted.
  4. SQLite Explain Query Plan

From http://blog.raymccrae.scot/2017/12/core-data-sqldebug-log-levels.html

like image 8
J. Doe Avatar answered Nov 13 '22 23:11

J. Doe