Disable MagicalRecord error messages and warnings
Asked Answered
L

4

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

Lukelukens answered 16/10, 2012 at 6:14 Comment(1)
If you are using Cocoapods, this is what you need: #15284567Affine
L
31

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

Lukelukens answered 11/12, 2012 at 23:59 Comment(3)
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 @Lukelukens has suggested is the right way to disable logging.Gherkin
@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?Bangtail
@Bangtail sorry, I had to change the method — here are the docs: github.com/magicalpanda/MagicalRecord/wiki/LoggingGherkin
P
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

Population answered 30/6, 2014 at 8:18 Comment(0)
D
6

swift

MagicalRecord.setLoggingLevel(MagicalRecordLoggingLevel.Off)

objC

[MagicalRecord setLoggingLevel:MagicalRecordLogLevelOff];

put it in your AppDelegate when the application didFinishLaunchingWithOptions

Dwanadwane answered 11/1, 2016 at 14:30 Comment(1)
Now it seems it's [MagicalRecord setLoggingLevel: MagicalRecordLoggingLevelOff];Kimono
D
3

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

Devland answered 16/10, 2012 at 6:47 Comment(2)
once I turned off record logging, there were no more error messages.Lukelukens
once I stopped going to the dentist, there were no more cavities.Fettle

© 2022 - 2024 — McMap. All rights reserved.