Permalink
Browse files

Update logging documentation.

Closes #748.
  • Loading branch information...
tonyarnold committed May 18, 2014
1 parent 39c49b3 commit 0048b82be80bcceab68031f98567398eefd437d5
Showing with 32 additions and 3 deletions.
  1. +32 −3 Docs/Logging.md
View
@@ -1,6 +1,35 @@
## Logging
-MagicalRecord has logging built in to every fetch request and other Core Data operation. When errors occur when fetching or saving data, these errors are captured by MagicalRecord. By default, these logs use NSLog to present logging information. However, if you have CocoaLumberjack installed in your project, MagicalRecord will use CocoaLumberjack and it's configuration to send logs to their proper output.
-All logging in MagicalRecord can be disabled by placing this define preprocessor statement prior to the main import of CoreData+MagicalRecord.h
+MagicalRecord has logging built in to most of it's interactions with Core Data. When errors occur during fetching or saving data, these errors are captured and (if you've enabled them) logged to the console.
- #define MR_ENABLE_ACTIVE_RECORD_LOGGING 0
+Logging can be enabled by placing the following preprocessor statement before your first import of `CoreData+MagicalRecord.h`, like so:
+
+```objective-c
+#define MR_LOGGING_ENABLED 1
+#import <MagicalRecord/CoreData+MagicalRecord.h>
+```
+
+Logging can be configured by calling `[MagicalRecord setLoggingMask:…];` using one of the predefined logging masks:
+
+- **MagicalRecordLogMaskOff**: Don't log anything
+- **MagicalRecordLoggingMaskFatal**: Log all fatal messages
+- **MagicalRecordLoggingMaskError**: Log all errors and fatal messages
+- **MagicalRecordLoggingMaskWarn**: Log warnings, errors and fatal messages
+- **MagicalRecordLoggingMaskInfo**: Log informative, warning and error messages
+- **MagicalRecordLoggingMaskVerbose**: Log verbose diagnostic, informative, warning and error messages
+
+The logging level defaults to `MagicalRecordLoggingMaskWarn`.
+
+## Disabling Logs
+
+Setting the logging mask to **MagicalRecordLogMaskOff** completely disables MagicalRecord's logging.
+
+## CocoaLumberjack
+
+If it's available, MagicalRecord will direct it's logs to [CocoaLumberjack](https://github.com/CocoaLumberjack/CocoaLumberjack). All you need to do is make sure you've imported CocoaLumberjack before you import MagicalRecord, like so:
+
+```objective-c
+#import <CocoaLumberjack/DDLog.h>
+#define MR_LOGGING_ENABLED 1
+#import <MagicalRecord/CoreData+MagicalRecord.h>
+```

0 comments on commit 0048b82

Please sign in to comment.