Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding sample implementation of a CoreDataLogger.

  • Loading branch information...
commit fd0e8cef9db876b56c4c2f6fe23c5bd020a97061 1 parent 2e9c50a
@robbiehanson robbiehanson authored
Showing with 5,038 additions and 0 deletions.
  1. +7 −0 Xcode/BenchmarkMac/BenchmarkMac.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  2. +349 −0 Xcode/CoreDataLogger/CoreDataLogger.xcodeproj/project.pbxproj
  3. +7 −0 Xcode/CoreDataLogger/CoreDataLogger.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  4. +32 −0 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLogger-Info.plist
  5. +7 −0 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLogger-Prefix.pch
  6. +41 −0 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLogger.h
  7. +327 −0 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLogger.m
  8. +5 −0 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLogger.xcdatamodeld/.xccurrentversion
  9. +14 −0 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLoggerAppDelegate.h
  10. +54 −0 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLoggerAppDelegate.m
  11. +8 −0 Xcode/CoreDataLogger/CoreDataLogger/Log.xcdatamodeld/.xccurrentversion
  12. BIN  Xcode/CoreDataLogger/CoreDataLogger/Log.xcdatamodeld/CocoaBotLog.xcdatamodel/elements
  13. BIN  Xcode/CoreDataLogger/CoreDataLogger/Log.xcdatamodeld/CocoaBotLog.xcdatamodel/layout
  14. +12 −0 Xcode/CoreDataLogger/CoreDataLogger/LogEntry.h
  15. +11 −0 Xcode/CoreDataLogger/CoreDataLogger/LogEntry.m
  16. +29 −0 Xcode/CoreDataLogger/CoreDataLogger/en.lproj/Credits.rtf
  17. +2 −0  Xcode/CoreDataLogger/CoreDataLogger/en.lproj/InfoPlist.strings
  18. +4,119 −0 Xcode/CoreDataLogger/CoreDataLogger/en.lproj/MainMenu.xib
  19. +14 −0 Xcode/CoreDataLogger/CoreDataLogger/main.m
View
7 Xcode/BenchmarkMac/BenchmarkMac.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:BenchmarkMac.xcodeproj">
+ </FileRef>
+</Workspace>
View
349 Xcode/CoreDataLogger/CoreDataLogger.xcodeproj/project.pbxproj
@@ -0,0 +1,349 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ DCE86C0E1343C419004FD85F /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCE86C0D1343C419004FD85F /* Cocoa.framework */; };
+ DCE86C181343C419004FD85F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = DCE86C161343C419004FD85F /* InfoPlist.strings */; };
+ DCE86C1B1343C419004FD85F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DCE86C1A1343C419004FD85F /* main.m */; };
+ DCE86C1E1343C419004FD85F /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = DCE86C1C1343C419004FD85F /* Credits.rtf */; };
+ DCE86C211343C419004FD85F /* CoreDataLoggerAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DCE86C201343C419004FD85F /* CoreDataLoggerAppDelegate.m */; };
+ DCE86C241343C41A004FD85F /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = DCE86C221343C41A004FD85F /* MainMenu.xib */; };
+ DCE86C411343C44D004FD85F /* DDAbstractDatabaseLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = DCE86C381343C44D004FD85F /* DDAbstractDatabaseLogger.m */; };
+ DCE86C441343C44D004FD85F /* DDLog.m in Sources */ = {isa = PBXBuildFile; fileRef = DCE86C3E1343C44D004FD85F /* DDLog.m */; };
+ DCE86C451343C44D004FD85F /* DDTTYLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = DCE86C401343C44D004FD85F /* DDTTYLogger.m */; };
+ DCE86C551343C64F004FD85F /* CoreDataLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = DCE86C501343C64F004FD85F /* CoreDataLogger.m */; };
+ DCE86C561343C64F004FD85F /* Log.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = DCE86C511343C64F004FD85F /* Log.xcdatamodeld */; };
+ DCE86C571343C64F004FD85F /* LogEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = DCE86C541343C64F004FD85F /* LogEntry.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ DCE86C091343C419004FD85F /* CoreDataLogger.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CoreDataLogger.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ DCE86C0D1343C419004FD85F /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
+ DCE86C101343C419004FD85F /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
+ DCE86C111343C419004FD85F /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
+ DCE86C121343C419004FD85F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ DCE86C151343C419004FD85F /* CoreDataLogger-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CoreDataLogger-Info.plist"; sourceTree = "<group>"; };
+ DCE86C171343C419004FD85F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ DCE86C191343C419004FD85F /* CoreDataLogger-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CoreDataLogger-Prefix.pch"; sourceTree = "<group>"; };
+ DCE86C1A1343C419004FD85F /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ DCE86C1D1343C419004FD85F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = "<group>"; };
+ DCE86C1F1343C419004FD85F /* CoreDataLoggerAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreDataLoggerAppDelegate.h; sourceTree = "<group>"; };
+ DCE86C201343C419004FD85F /* CoreDataLoggerAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CoreDataLoggerAppDelegate.m; sourceTree = "<group>"; };
+ DCE86C231343C41A004FD85F /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
+ DCE86C371343C44D004FD85F /* DDAbstractDatabaseLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDAbstractDatabaseLogger.h; path = ../../Lumberjack/DDAbstractDatabaseLogger.h; sourceTree = "<group>"; };
+ DCE86C381343C44D004FD85F /* DDAbstractDatabaseLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDAbstractDatabaseLogger.m; path = ../../Lumberjack/DDAbstractDatabaseLogger.m; sourceTree = "<group>"; };
+ DCE86C3D1343C44D004FD85F /* DDLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDLog.h; path = ../../Lumberjack/DDLog.h; sourceTree = "<group>"; };
+ DCE86C3E1343C44D004FD85F /* DDLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDLog.m; path = ../../Lumberjack/DDLog.m; sourceTree = "<group>"; };
+ DCE86C3F1343C44D004FD85F /* DDTTYLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDTTYLogger.h; path = ../../Lumberjack/DDTTYLogger.h; sourceTree = "<group>"; };
+ DCE86C401343C44D004FD85F /* DDTTYLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDTTYLogger.m; path = ../../Lumberjack/DDTTYLogger.m; sourceTree = "<group>"; };
+ DCE86C4F1343C64F004FD85F /* CoreDataLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CoreDataLogger.h; path = CoreDataLogger/CoreDataLogger.h; sourceTree = "<group>"; };
+ DCE86C501343C64F004FD85F /* CoreDataLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CoreDataLogger.m; path = CoreDataLogger/CoreDataLogger.m; sourceTree = "<group>"; };
+ DCE86C521343C64F004FD85F /* CocoaBotLog.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = CocoaBotLog.xcdatamodel; sourceTree = "<group>"; };
+ DCE86C531343C64F004FD85F /* LogEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LogEntry.h; path = CoreDataLogger/LogEntry.h; sourceTree = "<group>"; };
+ DCE86C541343C64F004FD85F /* LogEntry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LogEntry.m; path = CoreDataLogger/LogEntry.m; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ DCE86C061343C419004FD85F /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ DCE86C0E1343C419004FD85F /* Cocoa.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ DCE86BFE1343C419004FD85F = {
+ isa = PBXGroup;
+ children = (
+ DCE86C351343C432004FD85F /* Logging */,
+ DCE86C131343C419004FD85F /* CoreDataLogger */,
+ DCE86C0C1343C419004FD85F /* Frameworks */,
+ DCE86C0A1343C419004FD85F /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ DCE86C0A1343C419004FD85F /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ DCE86C091343C419004FD85F /* CoreDataLogger.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ DCE86C0C1343C419004FD85F /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ DCE86C0D1343C419004FD85F /* Cocoa.framework */,
+ DCE86C0F1343C419004FD85F /* Other Frameworks */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ DCE86C0F1343C419004FD85F /* Other Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ DCE86C101343C419004FD85F /* AppKit.framework */,
+ DCE86C111343C419004FD85F /* CoreData.framework */,
+ DCE86C121343C419004FD85F /* Foundation.framework */,
+ );
+ name = "Other Frameworks";
+ sourceTree = "<group>";
+ };
+ DCE86C131343C419004FD85F /* CoreDataLogger */ = {
+ isa = PBXGroup;
+ children = (
+ DCE86C1F1343C419004FD85F /* CoreDataLoggerAppDelegate.h */,
+ DCE86C201343C419004FD85F /* CoreDataLoggerAppDelegate.m */,
+ DCE86C221343C41A004FD85F /* MainMenu.xib */,
+ DCE86C141343C419004FD85F /* Supporting Files */,
+ );
+ path = CoreDataLogger;
+ sourceTree = "<group>";
+ };
+ DCE86C141343C419004FD85F /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ DCE86C151343C419004FD85F /* CoreDataLogger-Info.plist */,
+ DCE86C161343C419004FD85F /* InfoPlist.strings */,
+ DCE86C191343C419004FD85F /* CoreDataLogger-Prefix.pch */,
+ DCE86C1A1343C419004FD85F /* main.m */,
+ DCE86C1C1343C419004FD85F /* Credits.rtf */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+ DCE86C351343C432004FD85F /* Logging */ = {
+ isa = PBXGroup;
+ children = (
+ DCE86C3D1343C44D004FD85F /* DDLog.h */,
+ DCE86C3E1343C44D004FD85F /* DDLog.m */,
+ DCE86C3F1343C44D004FD85F /* DDTTYLogger.h */,
+ DCE86C401343C44D004FD85F /* DDTTYLogger.m */,
+ DCE86C371343C44D004FD85F /* DDAbstractDatabaseLogger.h */,
+ DCE86C381343C44D004FD85F /* DDAbstractDatabaseLogger.m */,
+ DCE86C361343C43C004FD85F /* CoreData */,
+ );
+ name = Logging;
+ sourceTree = "<group>";
+ };
+ DCE86C361343C43C004FD85F /* CoreData */ = {
+ isa = PBXGroup;
+ children = (
+ DCE86C511343C64F004FD85F /* Log.xcdatamodeld */,
+ DCE86C531343C64F004FD85F /* LogEntry.h */,
+ DCE86C541343C64F004FD85F /* LogEntry.m */,
+ DCE86C4F1343C64F004FD85F /* CoreDataLogger.h */,
+ DCE86C501343C64F004FD85F /* CoreDataLogger.m */,
+ );
+ name = CoreData;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ DCE86C081343C419004FD85F /* CoreDataLogger */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = DCE86C2A1343C41A004FD85F /* Build configuration list for PBXNativeTarget "CoreDataLogger" */;
+ buildPhases = (
+ DCE86C051343C419004FD85F /* Sources */,
+ DCE86C061343C419004FD85F /* Frameworks */,
+ DCE86C071343C419004FD85F /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = CoreDataLogger;
+ productName = CoreDataLogger;
+ productReference = DCE86C091343C419004FD85F /* CoreDataLogger.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ DCE86C001343C419004FD85F /* Project object */ = {
+ isa = PBXProject;
+ buildConfigurationList = DCE86C031343C419004FD85F /* Build configuration list for PBXProject "CoreDataLogger" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = DCE86BFE1343C419004FD85F;
+ productRefGroup = DCE86C0A1343C419004FD85F /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ DCE86C081343C419004FD85F /* CoreDataLogger */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ DCE86C071343C419004FD85F /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ DCE86C181343C419004FD85F /* InfoPlist.strings in Resources */,
+ DCE86C1E1343C419004FD85F /* Credits.rtf in Resources */,
+ DCE86C241343C41A004FD85F /* MainMenu.xib in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ DCE86C051343C419004FD85F /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ DCE86C1B1343C419004FD85F /* main.m in Sources */,
+ DCE86C211343C419004FD85F /* CoreDataLoggerAppDelegate.m in Sources */,
+ DCE86C411343C44D004FD85F /* DDAbstractDatabaseLogger.m in Sources */,
+ DCE86C441343C44D004FD85F /* DDLog.m in Sources */,
+ DCE86C451343C44D004FD85F /* DDTTYLogger.m in Sources */,
+ DCE86C551343C64F004FD85F /* CoreDataLogger.m in Sources */,
+ DCE86C561343C64F004FD85F /* Log.xcdatamodeld in Sources */,
+ DCE86C571343C64F004FD85F /* LogEntry.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ DCE86C161343C419004FD85F /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ DCE86C171343C419004FD85F /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+ DCE86C1C1343C419004FD85F /* Credits.rtf */ = {
+ isa = PBXVariantGroup;
+ children = (
+ DCE86C1D1343C419004FD85F /* en */,
+ );
+ name = Credits.rtf;
+ sourceTree = "<group>";
+ };
+ DCE86C221343C41A004FD85F /* MainMenu.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ DCE86C231343C41A004FD85F /* en */,
+ );
+ name = MainMenu.xib;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ DCE86C281343C41A004FD85F /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
+ };
+ name = Debug;
+ };
+ DCE86C291343C41A004FD85F /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ SDKROOT = macosx;
+ };
+ name = Release;
+ };
+ DCE86C2B1343C41A004FD85F /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "CoreDataLogger/CoreDataLogger-Prefix.pch";
+ INFOPLIST_FILE = "CoreDataLogger/CoreDataLogger-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ DCE86C2C1343C41A004FD85F /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "CoreDataLogger/CoreDataLogger-Prefix.pch";
+ INFOPLIST_FILE = "CoreDataLogger/CoreDataLogger-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ DCE86C031343C419004FD85F /* Build configuration list for PBXProject "CoreDataLogger" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ DCE86C281343C41A004FD85F /* Debug */,
+ DCE86C291343C41A004FD85F /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ DCE86C2A1343C41A004FD85F /* Build configuration list for PBXNativeTarget "CoreDataLogger" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ DCE86C2B1343C41A004FD85F /* Debug */,
+ DCE86C2C1343C41A004FD85F /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ };
+/* End XCConfigurationList section */
+
+/* Begin XCVersionGroup section */
+ DCE86C511343C64F004FD85F /* Log.xcdatamodeld */ = {
+ isa = XCVersionGroup;
+ children = (
+ DCE86C521343C64F004FD85F /* CocoaBotLog.xcdatamodel */,
+ );
+ currentVersion = DCE86C521343C64F004FD85F /* CocoaBotLog.xcdatamodel */;
+ name = Log.xcdatamodeld;
+ path = CoreDataLogger/Log.xcdatamodeld;
+ sourceTree = "<group>";
+ versionGroupType = wrapper.xcdatamodel;
+ };
+/* End XCVersionGroup section */
+ };
+ rootObject = DCE86C001343C419004FD85F /* Project object */;
+}
View
7 Xcode/CoreDataLogger/CoreDataLogger.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:CoreDataLogger.xcodeproj">
+ </FileRef>
+</Workspace>
View
32 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLogger-Info.plist
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.deusty.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>${MACOSX_DEPLOYMENT_TARGET}</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
View
7 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLogger-Prefix.pch
@@ -0,0 +1,7 @@
+//
+// Prefix header for all source files of the 'CoreDataLogger' target in the 'CoreDataLogger' project
+//
+
+#ifdef __OBJC__
+ #import <Cocoa/Cocoa.h>
+#endif
View
41 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLogger.h
@@ -0,0 +1,41 @@
+#import <Foundation/Foundation.h>
+#import "DDAbstractDatabaseLogger.h"
+
+
+@interface CoreDataLogger : DDAbstractDatabaseLogger <DDLogger>
+{
+ @private
+ NSString *logDirectory;
+
+ NSManagedObjectModel *managedObjectModel;
+ NSPersistentStoreCoordinator *persistentStoreCoordinator;
+ NSManagedObjectContext *managedObjectContext;
+ NSEntityDescription *logEntryEntity;
+}
+
+/**
+ * Initializes an instance set to save it's CocoaBotLog.sqlite file to the given directory.
+ * If the directory doesn't already exist, it is automatically created.
+**/
+- (id)initWithLogDirectory:(NSString *)logDirectory;
+
+/**
+ * Provides access to the thread-safe components of the core data stack.
+ *
+ * Please note that NSManagedObjectContext is NOT thread-safe.
+ * The managedObjectContext in use by this instance is only to be used on it's private dispatch_queue.
+ * You must create your own managedObjectContext for your own use.
+**/
+@property (readonly) NSManagedObjectModel *managedObjectModel;
+@property (readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
+
+/**
+ * Clears the log by removing the persistentStore from the persistentStoreCoordinator,
+ * and deleting the Log.sqlite file from disk.
+ *
+ * Important: If you have created your own managedObjectContext for the Log,
+ * you MUST reset your context following an invocation of this method!
+**/
+- (void)clearLog;
+
+@end
View
327 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLogger.m
@@ -0,0 +1,327 @@
+#import "CoreDataLogger.h"
+#import "LogEntry.h"
+
+@interface CoreDataLogger (PrivateAPI)
+- (void)validateLogDirectory;
+- (void)createManagedObjectContext;
+@end
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark -
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+@implementation CoreDataLogger
+
+- (id)initWithLogDirectory:(NSString *)aLogDirectory
+{
+ if ((self = [super init]))
+ {
+ logDirectory = [aLogDirectory copy];
+
+ [self validateLogDirectory];
+ [self createManagedObjectContext];
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [logDirectory release];
+
+ [logEntryEntity release];
+ [managedObjectContext release];
+ [persistentStoreCoordinator release];
+ [managedObjectModel release];
+
+ [super dealloc];
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark Private API
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+- (void)validateLogDirectory
+{
+ // Validate log directory exists or create the directory.
+
+ BOOL isDirectory;
+ if ([[NSFileManager defaultManager] fileExistsAtPath:logDirectory isDirectory:&isDirectory])
+ {
+ if (!isDirectory)
+ {
+ NSLog(@"%@: %@ - logDirectory(%@) is a file!", [self class], THIS_METHOD, logDirectory);
+
+ [logDirectory release];
+ logDirectory = nil;
+ }
+ }
+ else
+ {
+ NSError *error = nil;
+
+ BOOL result = [[NSFileManager defaultManager] createDirectoryAtPath:logDirectory
+ withIntermediateDirectories:YES
+ attributes:nil
+ error:&error];
+ if (!result)
+ {
+ NSLog(@"%@: %@ - Unable to create logDirectory(%@) due to error: %@",
+ [self class], THIS_METHOD, logDirectory, error);
+
+ [logDirectory release];
+ logDirectory = nil;
+ }
+ }
+}
+
+- (NSString *)logFilePath
+{
+ return [logDirectory stringByAppendingPathComponent:@"Log.sqlite"];
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark Core Data
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+- (NSManagedObjectModel *)managedObjectModel
+{
+ if (managedObjectModel)
+ {
+ return managedObjectModel;
+ }
+
+ NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Log" withExtension:@"momd"];
+ managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
+ return managedObjectModel;
+}
+
+- (BOOL)addPersistentStore:(NSError **)errorPtr
+{
+ if (logDirectory == nil)
+ {
+ if (errorPtr)
+ {
+ NSString *errMsg = @"Invalid logDirectory";
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:errMsg forKey:NSLocalizedDescriptionKey];
+
+ *errorPtr = [NSError errorWithDomain:NSStringFromClass([self class]) code:0 userInfo:userInfo];
+ }
+ return NO;
+ }
+
+ NSURL *url = [NSURL fileURLWithPath:[self logFilePath]];
+
+ NSPersistentStore *result = [persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
+ configuration:nil
+ URL:url
+ options:nil
+ error:errorPtr];
+ return (result != nil);
+}
+
+- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
+{
+ if (persistentStoreCoordinator)
+ {
+ return persistentStoreCoordinator;
+ }
+
+ NSManagedObjectModel *mom = [self managedObjectModel];
+ if (!mom)
+ {
+ NSLog(@"%@: %@ - No model to generate a store from", [self class], THIS_FILE);
+ return nil;
+ }
+
+ if (logDirectory == nil)
+ {
+ return nil;
+ }
+
+ persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom];
+
+ NSError *error = nil;
+ if (![self addPersistentStore:&error])
+ {
+ NSLog(@"%@: %@ - Error creating persistent store: %@", [self class], THIS_FILE, error);
+
+ [persistentStoreCoordinator release];
+ persistentStoreCoordinator = nil;
+ }
+
+ return persistentStoreCoordinator;
+}
+
+- (void)createManagedObjectContext
+{
+ NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
+ if (coordinator)
+ {
+ if (managedObjectContext == nil)
+ {
+ managedObjectContext = [[NSManagedObjectContext alloc] init];
+ [managedObjectContext setPersistentStoreCoordinator:coordinator];
+ [managedObjectContext setMergePolicy:NSOverwriteMergePolicy];
+ }
+
+ if (logEntryEntity == nil)
+ {
+ logEntryEntity = [[NSEntityDescription entityForName:@"LogEntry"
+ inManagedObjectContext:managedObjectContext] retain];
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark Public API
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+- (void)clearLog
+{
+ dispatch_block_t block = ^{
+
+ if (managedObjectContext == nil)
+ {
+ return;
+ }
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSError *error = nil;
+
+ [managedObjectContext reset];
+ [persistentStoreCoordinator lock];
+
+ NSPersistentStore *store = [[persistentStoreCoordinator persistentStores] lastObject];
+
+ if (![persistentStoreCoordinator removePersistentStore:store error:&error])
+ {
+ NSLog(@"%@: %@ - Error removing persistent store: %@", [self class], THIS_METHOD, error);
+ }
+
+ NSString *logFilePath = [self logFilePath];
+
+ if ([[NSFileManager defaultManager] fileExistsAtPath:logFilePath])
+ {
+ if (![[NSFileManager defaultManager] removeItemAtPath:logFilePath error:&error])
+ {
+ NSLog(@"%@: %@ - Error deleting log file: %@", [self class], THIS_METHOD, error);
+ }
+ }
+
+ if (![self addPersistentStore:&error])
+ {
+ NSLog(@"%@: %@ - Error creating persistent store: %@", [self class], THIS_FILE, error);
+ }
+
+ [persistentStoreCoordinator unlock];
+
+ [pool drain];
+ };
+
+ if (dispatch_get_current_queue() == loggerQueue)
+ block();
+ else
+ dispatch_async(loggerQueue, block);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark DDLogger
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+- (BOOL)db_log:(DDLogMessage *)logMessage
+{
+ if (managedObjectContext == nil)
+ {
+ return NO;
+ }
+
+ LogEntry *logEntry = [[NSManagedObject alloc] initWithEntity:logEntryEntity
+ insertIntoManagedObjectContext:managedObjectContext];
+
+ logEntry.context = [NSNumber numberWithInt:logMessage->logContext];
+ logEntry.level = [NSNumber numberWithInt:logMessage->logFlag];
+ logEntry.message = logMessage->logMsg;
+ logEntry.timestamp = logMessage->timestamp;
+
+ [logEntry release];
+
+ return YES;
+}
+
+- (void)saveContext
+{
+ if ([managedObjectContext hasChanges])
+ {
+ NSError *error = nil;
+ if (![managedObjectContext save:&error])
+ {
+ NSLog(@"%@: Error saving: %@ %@", [self class], error, [error userInfo]);
+
+ // Since the save failed, we are forced to dump the log entries.
+ // If we don't we risk an ever growing managedObjectContext,
+ // as the unsaved changes sit around in RAM until either saved or dumped.
+
+ [managedObjectContext rollback];
+ }
+ }
+}
+
+- (void)deleteOldLogEntries:(BOOL)shouldSaveWhenDone
+{
+ if (maxAge <= 0.0)
+ {
+ // Deleting old log entries is disabled.
+ // The superclass won't likely call us if this is the case, but we're being cautious.
+ return;
+ }
+
+ NSEntityDescription *entity = [NSEntityDescription entityForName:@"LogEntry"
+ inManagedObjectContext:managedObjectContext];
+
+ NSDate *maxDate = [NSDate dateWithTimeIntervalSinceNow:(-1.0 * maxAge)];
+ NSPredicate *predicate = [NSPredicate predicateWithFormat:@"timestamp < %@", maxDate];
+
+ NSUInteger batchSize = (saveThreshold > 0) ? saveThreshold : 500;
+ NSUInteger count = 0;
+
+ NSFetchRequest *fetchRequest = [[[NSFetchRequest alloc] init] autorelease];
+ [fetchRequest setEntity:entity];
+ [fetchRequest setFetchBatchSize:batchSize];
+ [fetchRequest setPredicate:predicate];
+
+ NSArray *oldLogEntries = [managedObjectContext executeFetchRequest:fetchRequest error:nil];
+
+ for (LogEntry *logEntry in oldLogEntries)
+ {
+ [managedObjectContext deleteObject:logEntry];
+
+ if (++count >= batchSize)
+ {
+ [self saveContext];
+ }
+ }
+
+ if (shouldSaveWhenDone)
+ {
+ [self saveContext];
+ }
+}
+
+- (void)db_save
+{
+ [self saveContext];
+}
+
+- (void)db_delete
+{
+ [self deleteOldLogEntries:YES];
+}
+
+- (void)db_saveAndDelete
+{
+ [self deleteOldLogEntries:NO];
+ [self saveContext];
+}
+
+@end
View
5 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLogger.xcdatamodeld/.xccurrentversion
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict/>
+</plist>
View
14 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLoggerAppDelegate.h
@@ -0,0 +1,14 @@
+#import <Cocoa/Cocoa.h>
+
+@class CoreDataLogger;
+
+
+@interface CoreDataLoggerAppDelegate : NSObject <NSApplicationDelegate> {
+@private
+ CoreDataLogger *coreDataLogger;
+ NSWindow *window;
+}
+
+@property (assign) IBOutlet NSWindow *window;
+
+@end
View
54 Xcode/CoreDataLogger/CoreDataLogger/CoreDataLoggerAppDelegate.m
@@ -0,0 +1,54 @@
+#import "CoreDataLoggerAppDelegate.h"
+#import "DDLog.h"
+#import "DDTTYLogger.h"
+#import "CoreDataLogger.h"
+
+// Log levels: off, error, warn, info, verbose
+static const int ddLogLevel = LOG_LEVEL_VERBOSE;
+
+
+@implementation CoreDataLoggerAppDelegate
+
+@synthesize window;
+
+- (NSString *)applicationFilesDirectory
+{
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
+ NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : NSTemporaryDirectory();
+
+ return [basePath stringByAppendingPathComponent:@"CoreDataLogger"];
+}
+
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
+{
+// [DDLog addLogger:[DDTTYLogger sharedInstance]];
+
+ coreDataLogger = [[CoreDataLogger alloc] initWithLogDirectory:[self applicationFilesDirectory]];
+
+ coreDataLogger.saveThreshold = 500;
+ coreDataLogger.saveInterval = 60; // 60 seconds
+ coreDataLogger.maxAge = 60 * 60 * 24 * 7; // 7 days
+ coreDataLogger.deleteInterval = 60 * 5; // 5 minutes
+ coreDataLogger.deleteOnEverySave = NO;
+
+ [DDLog addLogger:coreDataLogger];
+
+ [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(doTest:) userInfo:nil repeats:NO];
+}
+
+- (void)doTest:(NSTimer *)aTimer
+{
+ NSDate *start = [NSDate date];
+
+ int i;
+ for (i = 0; i < 1000; i++)
+ {
+ DDLogVerbose(@"A log message of average size");
+ }
+ [DDLog flushLog];
+
+ NSTimeInterval elapsed = [start timeIntervalSinceNow] * -1.0;
+ NSLog(@"Total time: %.4f", elapsed);
+}
+
+@end
View
8 Xcode/CoreDataLogger/CoreDataLogger/Log.xcdatamodeld/.xccurrentversion
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>_XCCurrentVersionName</key>
+ <string>CocoaBotLog.xcdatamodel</string>
+</dict>
+</plist>
View
BIN  Xcode/CoreDataLogger/CoreDataLogger/Log.xcdatamodeld/CocoaBotLog.xcdatamodel/elements
Binary file not shown
View
BIN  Xcode/CoreDataLogger/CoreDataLogger/Log.xcdatamodeld/CocoaBotLog.xcdatamodel/layout
Binary file not shown
View
12 Xcode/CoreDataLogger/CoreDataLogger/LogEntry.h
@@ -0,0 +1,12 @@
+#import <Foundation/Foundation.h>
+#import <CoreData/CoreData.h>
+
+
+@interface LogEntry : NSManagedObject
+
+@property (nonatomic, retain) NSNumber * context;
+@property (nonatomic, retain) NSNumber * level;
+@property (nonatomic, retain) NSString * message;
+@property (nonatomic, retain) NSDate * timestamp;
+
+@end
View
11 Xcode/CoreDataLogger/CoreDataLogger/LogEntry.m
@@ -0,0 +1,11 @@
+#import "LogEntry.h"
+
+
+@implementation LogEntry
+
+@dynamic context;
+@dynamic level;
+@dynamic message;
+@dynamic timestamp;
+
+@end
View
29 Xcode/CoreDataLogger/CoreDataLogger/en.lproj/Credits.rtf
@@ -0,0 +1,29 @@
+{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\paperw9840\paperh8400
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\b\fs24 \cf0 Engineering:
+\b0 \
+ Some people\
+\
+
+\b Human Interface Design:
+\b0 \
+ Some other people\
+\
+
+\b Testing:
+\b0 \
+ Hopefully not nobody\
+\
+
+\b Documentation:
+\b0 \
+ Whoever\
+\
+
+\b With special thanks to:
+\b0 \
+ Mom\
+}
View
2  Xcode/CoreDataLogger/CoreDataLogger/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
View
4,119 Xcode/CoreDataLogger/CoreDataLogger/en.lproj/MainMenu.xib
4,119 additions, 0 deletions not shown
View
14 Xcode/CoreDataLogger/CoreDataLogger/main.m
@@ -0,0 +1,14 @@
+//
+// main.m
+// CoreDataLogger
+//
+// Created by Robbie Hanson on 3/30/11.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+int main(int argc, char *argv[])
+{
+ return NSApplicationMain(argc, (const char **)argv);
+}
Please sign in to comment.
Something went wrong with that request. Please try again.