12

I just started using MagicalRecord, and this might be a stupid question, but it's really bothering me... I am using MagicalRecord with sqlite, and when I initiate MagicalRecord, I used

[MagicalRecord setupCoreDataStackWithStoreNamed:@"OrderSystem.sqlite"];

and it produced the following messages:

2012-10-16 16:54:48.966 OrderSystem[4135:c07] +NSManagedObjectContext(MagicalRecord) MR_contextWithStoreCoordinator: -> Created : Context * MAIN THREAD *

When I tried to store my entity with the following code using a background thread:

[MagicalRecord saveInBackgroundWithBlock:^(NSManagedObjectContext *localContext){        
    Menu *localMenu = [menu inContext:localContext];        
    localMenu.name = menu.name;
    localMenu.menuid = menu.menuid ;        
}];

And I got the following error messages:

2012-10-16 17:05:20.118 OrderSystem[4523:4603] +MagicalRecord(ErrorHandling) defaultErrorHandler: Error Message: The operation couldn’t be completed. (Cocoa error 133000.)

2012-10-16 17:05:20.118 OrderSystem[4523:4603] +MagicalRecord(ErrorHandling) defaultErrorHandler: Error Domain: NSCocoaErrorDomain

2012-10-16 17:05:20.119 OrderSystem[4523:4603] +MagicalRecord(ErrorHandling) defaultErrorHandler: Recovery Suggestion: (null)

2012-10-16 17:05:20.119 OrderSystem[4523:4603] -NSManagedObjectContext(MagicalSaves) MR_saveWithErrorCallback: NO CHANGES IN CONTEXT : Context - NOT SAVING

2012-10-16 17:05:20.120 OrderSystem[4523:c07] -NSManagedObjectContext(MagicalSaves) MR_saveWithErrorCallback: -> Saving : * DEFAULT Context MAIN THREAD *

2012-10-16 17:05:20.121 OrderSystem[4523:c07] -NSManagedObjectContext(MagicalRecord) contextWillSave: Context : * DEFAULT Context MAIN THREAD * is about to save. Obtaining permanent IDs for new 1 inserted objects

2012-10-16 17:05:20.142 OrderSystem[4523:1303] -NSManagedObjectContext(MagicalSaves) MR_saveWithErrorCallback: -> Saving : * BACKGROUND SAVE * Context

2012-10-16 17:05:20.142 OrderSystem[4523:1303] -NSManagedObjectContext(MagicalRecord) contextWillSave: Context : * BACKGROUND SAVE * Context is about to save. Obtaining permanent IDs for new 1 inserted objects

When I check my stored data entity using findAll, it does seem to be stored in the database. And if I close the application completely, and relaunch the application, the entity is still there (which suggest the entity had been stored persistently, and not just in the memory). So it seems like everything is working, but any idea what are those error messages? and is there any way to turn them off? or solve them? because it's blocking my other NSLog...

Thank you

hook38
  • 3,899
  • 4
  • 32
  • 52
  • 2
    If you are using Cocoapods, this is what you need: http://stackoverflow.com/questions/15284067/cocoapods-turning-magicalrecord-logging-off/15284069 – Andres Kievsky Mar 07 '13 at 23:45

4 Answers4

31

found it. add #define MR_ENABLE_ACTIVE_RECORD_LOGGING 0 in your Prefix.pch file before #import "CoreData+MagicalRecord.h"

James Zaghini
  • 3,895
  • 4
  • 45
  • 61
hook38
  • 3,899
  • 4
  • 32
  • 52
  • 1
    We've changed the way logging works in the upcoming MagicalRecord 2.3 release — you'll be able to call `[MagicalRecord setLogLevel:MagicalRecordLogLevelOff];` (or a number of other levels) to disable these logging messages once it's released. For pre-2.3 releases, what @hook38 has suggested is the right way to disable logging. – Tony Arnold Apr 10 '14 at 09:43
  • @Tony Arnold. Git says my current MR code is up to date as of May 5 14 with "origin/develop". MR_ENABLE_ACTIVE_RECORD_LOGGING is no longer having any effect but `[MagicalRecord setLogLevel:]` is not found. I did find a `setLoggingMask:` in MagicalRecord+Options.m. What can I do to turn off the normal MR save logging output or turn it back on as needed? – chadbag May 05 '14 at 19:00
  • @chadbag sorry, I had to change the method — here are the docs: https://github.com/magicalpanda/MagicalRecord/wiki/Logging – Tony Arnold May 06 '14 at 00:31
20

In case you use pods add preprocessor macro MR_ENABLE_ACTIVE_RECORD_LOGGING=0 to magical record project like this: enter image description here

Nikolay Shubenkov
  • 3,133
  • 1
  • 29
  • 31
6

swift

MagicalRecord.setLoggingLevel(MagicalRecordLoggingLevel.Off)

objC

[MagicalRecord setLoggingLevel:MagicalRecordLogLevelOff];

put it in your AppDelegate when the application didFinishLaunchingWithOptions

Alberto Scampini
  • 798
  • 9
  • 27
2

It looks like you still have errors to fix. I suggest not ignoring those during development...

casademora
  • 67,775
  • 17
  • 69
  • 78