mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Merge branch 'master' of git://github.com/cappuccino/cappuccino
This commit is contained in:
@@ -29,12 +29,8 @@
|
||||
6824CDF01B0E9F1400F73447 /* XCCOperationError.m in Sources */ = {isa = PBXBuildFile; fileRef = 6824CDEF1B0E9F1400F73447 /* XCCOperationError.m */; };
|
||||
6841F2441AF98CE600CFE60E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6841F2431AF98CE600CFE60E /* main.m */; };
|
||||
6841F2461AF98CE600CFE60E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6841F2451AF98CE600CFE60E /* Images.xcassets */; };
|
||||
6841F2651AF98DCB00CFE60E /* DDASLLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 6841F2601AF98DCB00CFE60E /* DDASLLogger.m */; };
|
||||
6841F2661AF98DCB00CFE60E /* DDLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 6841F2621AF98DCB00CFE60E /* DDLog.m */; };
|
||||
6841F2671AF98DCB00CFE60E /* DDTTYLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 6841F2641AF98DCB00CFE60E /* DDTTYLogger.m */; };
|
||||
6841F26C1AF98DDD00CFE60E /* mod_pbxproj.py in Resources */ = {isa = PBXBuildFile; fileRef = 6841F2691AF98DDD00CFE60E /* mod_pbxproj.py */; };
|
||||
6841F26E1AF98DDD00CFE60E /* pbxprojModifier.py in Resources */ = {isa = PBXBuildFile; fileRef = 6841F26B1AF98DDD00CFE60E /* pbxprojModifier.py */; };
|
||||
6841F2781AF98FA300CFE60E /* DDLogLevel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6841F2771AF98FA300CFE60E /* DDLogLevel.m */; };
|
||||
6841F27C1AF990C300CFE60E /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 6841F27A1AF990C300CFE60E /* Debug.xcconfig */; };
|
||||
6841F27D1AF990C300CFE60E /* Release.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 6841F27B1AF990C300CFE60E /* Release.xcconfig */; };
|
||||
6841F2A51AF9932300CFE60E /* project.pbxproj in Resources */ = {isa = PBXBuildFile; fileRef = 6841F28A1AF9932300CFE60E /* project.pbxproj */; };
|
||||
@@ -89,17 +85,9 @@
|
||||
6841F2401AF98CE600CFE60E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
6841F2431AF98CE600CFE60E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
6841F2451AF98CE600CFE60E /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = ../Images.xcassets; sourceTree = "<group>"; };
|
||||
6841F25F1AF98DCB00CFE60E /* DDASLLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDASLLogger.h; sourceTree = "<group>"; };
|
||||
6841F2601AF98DCB00CFE60E /* DDASLLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDASLLogger.m; sourceTree = "<group>"; };
|
||||
6841F2611AF98DCB00CFE60E /* DDLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDLog.h; sourceTree = "<group>"; };
|
||||
6841F2621AF98DCB00CFE60E /* DDLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDLog.m; sourceTree = "<group>"; };
|
||||
6841F2631AF98DCB00CFE60E /* DDTTYLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDTTYLogger.h; sourceTree = "<group>"; };
|
||||
6841F2641AF98DCB00CFE60E /* DDTTYLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDTTYLogger.m; sourceTree = "<group>"; };
|
||||
6841F2691AF98DDD00CFE60E /* mod_pbxproj.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = mod_pbxproj.py; sourceTree = "<group>"; };
|
||||
6841F26B1AF98DDD00CFE60E /* pbxprojModifier.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = pbxprojModifier.py; sourceTree = "<group>"; };
|
||||
6841F2741AF98F6F00CFE60E /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; };
|
||||
6841F2761AF98FA300CFE60E /* DDLogLevel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDLogLevel.h; sourceTree = "<group>"; };
|
||||
6841F2771AF98FA300CFE60E /* DDLogLevel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDLogLevel.m; sourceTree = "<group>"; };
|
||||
6841F2791AF9902B00CFE60E /* XcodeCapp-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "XcodeCapp-Prefix.pch"; sourceTree = "<group>"; };
|
||||
6841F27A1AF990C300CFE60E /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
|
||||
6841F27B1AF990C300CFE60E /* Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
|
||||
@@ -150,7 +138,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0275390E1B227D6700F6D824 /* YRKSpinningProgressIndicator */,
|
||||
6841F25E1AF98DCB00CFE60E /* Lumberjack */,
|
||||
);
|
||||
name = Externals;
|
||||
sourceTree = "<group>";
|
||||
@@ -246,19 +233,6 @@
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
6841F25E1AF98DCB00CFE60E /* Lumberjack */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6841F25F1AF98DCB00CFE60E /* DDASLLogger.h */,
|
||||
6841F2601AF98DCB00CFE60E /* DDASLLogger.m */,
|
||||
6841F2611AF98DCB00CFE60E /* DDLog.h */,
|
||||
6841F2621AF98DCB00CFE60E /* DDLog.m */,
|
||||
6841F2631AF98DCB00CFE60E /* DDTTYLogger.h */,
|
||||
6841F2641AF98DCB00CFE60E /* DDTTYLogger.m */,
|
||||
);
|
||||
path = Lumberjack;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
6841F2681AF98DDD00CFE60E /* Scripts */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -287,8 +261,6 @@
|
||||
6841F2B81AFA83E900CFE60E /* XCCUserDefaults.h */,
|
||||
6841F2BD1AFA965300CFE60E /* XCCTaskLauncher.h */,
|
||||
6841F2BE1AFA965300CFE60E /* XCCTaskLauncher.m */,
|
||||
6841F2761AF98FA300CFE60E /* DDLogLevel.h */,
|
||||
6841F2771AF98FA300CFE60E /* DDLogLevel.m */,
|
||||
6815BBE91AFC24430030D8BB /* XcodeProjectCloser.h */,
|
||||
6815BBEA1AFC24430030D8BB /* XcodeProjectCloser.m */,
|
||||
6863FBA11AFD55A900040C8E /* XCCFSEventLogUtils.h */,
|
||||
@@ -409,7 +381,6 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
6841F2781AF98FA300CFE60E /* DDLogLevel.m in Sources */,
|
||||
68B6BF321B1E2546003B265B /* XCCPPXOperation.m in Sources */,
|
||||
021B94701B20E31F00F12DDA /* XCCSettingsViewController.m in Sources */,
|
||||
0255B8401B1F71FB000CA4BC /* AppDelegate.m in Sources */,
|
||||
@@ -417,7 +388,6 @@
|
||||
6841F2BF1AFA965300CFE60E /* XCCTaskLauncher.m in Sources */,
|
||||
027539111B227D7500F6D824 /* YRKSpinningProgressIndicator.m in Sources */,
|
||||
6841F2C41AFABD7200CFE60E /* XCCCappuccinoProject.m in Sources */,
|
||||
6841F2661AF98DCB00CFE60E /* DDLog.m in Sources */,
|
||||
686ACD311B16397F0089EB03 /* XCCCappuccinoProjectController.m in Sources */,
|
||||
021B946C1B20D71200F12DDA /* XCCErrorsViewController.m in Sources */,
|
||||
021B94651B20CECA00F12DDA /* XCCOperationsViewController.m in Sources */,
|
||||
@@ -430,12 +400,10 @@
|
||||
686C69711B0FAE620095BB3C /* XCCOperationErrorHeaderDataView.m in Sources */,
|
||||
6824CDF01B0E9F1400F73447 /* XCCOperationError.m in Sources */,
|
||||
021B94751B21112500F12DDA /* XCCWelcomeView.m in Sources */,
|
||||
6841F2671AF98DCB00CFE60E /* DDTTYLogger.m in Sources */,
|
||||
6841F2441AF98CE600CFE60E /* main.m in Sources */,
|
||||
6824CDDA1B0D5AA700F73447 /* XCCOperationDataView.m in Sources */,
|
||||
6841F2CA1AFADEBC00CFE60E /* XCCSourcesFinderOperation.m in Sources */,
|
||||
681ADE8F1B0D032C00FC8E08 /* XCCPath.m in Sources */,
|
||||
6841F2651AF98DCB00CFE60E /* DDASLLogger.m in Sources */,
|
||||
6841F2B71AFA83D500CFE60E /* XCCUserDefaults.m in Sources */,
|
||||
6824CDEA1B0E9CDB00F73447 /* XCCOperationErrorDataView.m in Sources */,
|
||||
);
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
{
|
||||
NSDictionary *appDefaults = @{
|
||||
XCCUserDefaultsAutoOpenXcodeProject: @YES,
|
||||
XCCUserDefaultsLogLevel: @LOG_LEVEL_WARN,
|
||||
XCCUserDefaultsMaxNumberOfConcurrentOperations: @20
|
||||
};
|
||||
|
||||
@@ -40,26 +39,6 @@
|
||||
self->statusItem.length = self->imageStatusInactive.size.width + 12;
|
||||
}
|
||||
|
||||
- (void)_initLogging
|
||||
{
|
||||
#if DEBUG
|
||||
[DDLog addLogger:[DDTTYLogger sharedInstance]];
|
||||
[[DDTTYLogger sharedInstance] setColorsEnabled:YES];
|
||||
[DDLogLevel setLogLevel:LOG_LEVEL_VERBOSE];
|
||||
#else
|
||||
[DDLog addLogger:[DDASLLogger sharedInstance]];
|
||||
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
int logLevel = (int)[defaults integerForKey:XCCUserDefaultsLogLevel];
|
||||
NSUInteger modifiers = [NSEvent modifierFlags];
|
||||
|
||||
if (modifiers & NSAlternateKeyMask)
|
||||
logLevel = LOG_LEVEL_VERBOSE;
|
||||
|
||||
[DDLogLevel setLogLevel:logLevel];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)_initOperationQueue
|
||||
{
|
||||
self.mainOperationQueue = [NSOperationQueue new];
|
||||
@@ -116,12 +95,11 @@
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
DDLogVerbose(@"\n******************************\n** XcodeCapp started **\n******************************\n");
|
||||
NSLog(@"\n******************************\n** XcodeCapp started **\n******************************\n");
|
||||
|
||||
self.version = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
|
||||
|
||||
[self _initUserDefaults];
|
||||
[self _initLogging];
|
||||
[self _initOperationQueue];
|
||||
[self _initStatusItem];
|
||||
|
||||
@@ -132,7 +110,7 @@
|
||||
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)app
|
||||
{
|
||||
DDLogVerbose(@"Stop listening to all projects");
|
||||
NSLog(@"Stop listening to all projects");
|
||||
[self.mainWindowController notifyCappuccinoControllersApplicationIsClosing];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
@@ -141,7 +119,7 @@
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *)aNotification
|
||||
{
|
||||
DDLogVerbose(@"\n******************************\n** XcodeCapp stopped **\n******************************\n");
|
||||
NSLog(@"\n******************************\n** XcodeCapp stopped **\n******************************\n");
|
||||
}
|
||||
|
||||
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
//
|
||||
// DDLogLevel.h
|
||||
// XcodeCapp
|
||||
//
|
||||
// Created by Aparajita on 4/29/13.
|
||||
// Copyright (c) 2013 Cappuccino Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern int ddLogLevel;
|
||||
|
||||
@interface DDLogLevel : NSObject
|
||||
|
||||
+ (void)setLogLevel:(int)logLevel;
|
||||
|
||||
@end
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// DDLog.m
|
||||
// XcodeCapp
|
||||
//
|
||||
// Created by Aparajita on 4/29/13.
|
||||
// Copyright (c) 2013 Cappuccino Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DDLogLevel.h"
|
||||
|
||||
|
||||
int ddLogLevel = LOG_LEVEL_OFF;
|
||||
|
||||
|
||||
@implementation DDLogLevel
|
||||
|
||||
+ (int)ddLogLevel
|
||||
{
|
||||
return ddLogLevel;
|
||||
}
|
||||
|
||||
+ (void)setLogLevel:(int)logLevel
|
||||
{
|
||||
ddLogLevel = logLevel;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,41 +0,0 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <asl.h>
|
||||
|
||||
#import "DDLog.h"
|
||||
|
||||
/**
|
||||
* Welcome to Cocoa Lumberjack!
|
||||
*
|
||||
* The project page has a wealth of documentation if you have any questions.
|
||||
* https://github.com/robbiehanson/CocoaLumberjack
|
||||
*
|
||||
* If you're new to the project you may wish to read the "Getting Started" wiki.
|
||||
* https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
|
||||
*
|
||||
*
|
||||
* This class provides a logger for the Apple System Log facility.
|
||||
*
|
||||
* As described in the "Getting Started" page,
|
||||
* the traditional NSLog() function directs it's output to two places:
|
||||
*
|
||||
* - Apple System Log
|
||||
* - StdErr (if stderr is a TTY) so log statements show up in Xcode console
|
||||
*
|
||||
* To duplicate NSLog() functionality you can simply add this logger and a tty logger.
|
||||
* However, if you instead choose to use file logging (for faster performance),
|
||||
* you may choose to use a file logger and a tty logger.
|
||||
**/
|
||||
|
||||
@interface DDASLLogger : DDAbstractLogger <DDLogger>
|
||||
{
|
||||
aslclient client;
|
||||
}
|
||||
|
||||
+ (DDASLLogger *)sharedInstance;
|
||||
|
||||
// Inherited from DDAbstractLogger
|
||||
|
||||
// - (id <DDLogFormatter>)logFormatter;
|
||||
// - (void)setLogFormatter:(id <DDLogFormatter>)formatter;
|
||||
|
||||
@end
|
||||
@@ -1,99 +0,0 @@
|
||||
#import "DDASLLogger.h"
|
||||
|
||||
#import <libkern/OSAtomic.h>
|
||||
|
||||
/**
|
||||
* Welcome to Cocoa Lumberjack!
|
||||
*
|
||||
* The project page has a wealth of documentation if you have any questions.
|
||||
* https://github.com/robbiehanson/CocoaLumberjack
|
||||
*
|
||||
* If you're new to the project you may wish to read the "Getting Started" wiki.
|
||||
* https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
|
||||
**/
|
||||
|
||||
#if ! __has_feature(objc_arc)
|
||||
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
|
||||
#endif
|
||||
|
||||
|
||||
@implementation DDASLLogger
|
||||
|
||||
static DDASLLogger *sharedInstance;
|
||||
|
||||
/**
|
||||
* The runtime sends initialize to each class in a program exactly one time just before the class,
|
||||
* or any class that inherits from it, is sent its first message from within the program. (Thus the
|
||||
* method may never be invoked if the class is not used.) The runtime sends the initialize message to
|
||||
* classes in a thread-safe manner. Superclasses receive this message before their subclasses.
|
||||
*
|
||||
* This method may also be called directly (assumably by accident), hence the safety mechanism.
|
||||
**/
|
||||
+ (void)initialize
|
||||
{
|
||||
static BOOL initialized = NO;
|
||||
if (!initialized)
|
||||
{
|
||||
initialized = YES;
|
||||
|
||||
sharedInstance = [[DDASLLogger alloc] init];
|
||||
}
|
||||
}
|
||||
|
||||
+ (DDASLLogger *)sharedInstance
|
||||
{
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (sharedInstance != nil)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ((self = [super init]))
|
||||
{
|
||||
// A default asl client is provided for the main thread,
|
||||
// but background threads need to create their own client.
|
||||
|
||||
client = asl_open(NULL, "com.apple.console", 0);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)logMessage:(DDLogMessage *)logMessage
|
||||
{
|
||||
NSString *logMsg = logMessage->logMsg;
|
||||
|
||||
if (formatter)
|
||||
{
|
||||
logMsg = [formatter formatLogMessage:logMessage];
|
||||
}
|
||||
|
||||
if (logMsg)
|
||||
{
|
||||
const char *msg = [logMsg UTF8String];
|
||||
|
||||
int aslLogLevel;
|
||||
switch (logMessage->logLevel)
|
||||
{
|
||||
// Note: By default ASL will filter anything above level 5 (Notice).
|
||||
// So our mappings shouldn't go above that level.
|
||||
|
||||
case 1 : aslLogLevel = ASL_LEVEL_CRIT; break;
|
||||
case 2 : aslLogLevel = ASL_LEVEL_ERR; break;
|
||||
case 3 : aslLogLevel = ASL_LEVEL_WARNING; break;
|
||||
default : aslLogLevel = ASL_LEVEL_NOTICE; break;
|
||||
}
|
||||
|
||||
asl_log(client, NULL, aslLogLevel, "%s", msg);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)loggerName
|
||||
{
|
||||
return @"cocoa.lumberjack.aslLogger";
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,596 +0,0 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
* Welcome to Cocoa Lumberjack!
|
||||
*
|
||||
* The project page has a wealth of documentation if you have any questions.
|
||||
* https://github.com/robbiehanson/CocoaLumberjack
|
||||
*
|
||||
* If you're new to the project you may wish to read the "Getting Started" wiki.
|
||||
* https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
|
||||
*
|
||||
* Otherwise, here is a quick refresher.
|
||||
* There are three steps to using the macros:
|
||||
*
|
||||
* Step 1:
|
||||
* Import the header in your implementation file:
|
||||
*
|
||||
* #import "DDLog.h"
|
||||
*
|
||||
* Step 2:
|
||||
* Define your logging level in your implementation file:
|
||||
*
|
||||
* // Log levels: off, error, warn, info, verbose
|
||||
* static const int ddLogLevel = LOG_LEVEL_VERBOSE;
|
||||
*
|
||||
* Step 3:
|
||||
* Replace your NSLog statements with DDLog statements according to the severity of the message.
|
||||
*
|
||||
* NSLog(@"Fatal error, no dohickey found!"); -> DDLogError(@"Fatal error, no dohickey found!");
|
||||
*
|
||||
* DDLog works exactly the same as NSLog.
|
||||
* This means you can pass it multiple variables just like NSLog.
|
||||
**/
|
||||
|
||||
|
||||
@class DDLogMessage;
|
||||
|
||||
@protocol DDLogger;
|
||||
@protocol DDLogFormatter;
|
||||
|
||||
/**
|
||||
* This is the single macro that all other macros below compile into.
|
||||
* This big multiline macro makes all the other macros easier to read.
|
||||
**/
|
||||
|
||||
#define LOG_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, ...) \
|
||||
[DDLog log:isAsynchronous \
|
||||
level:lvl \
|
||||
flag:flg \
|
||||
context:ctx \
|
||||
file:__FILE__ \
|
||||
function:fnct \
|
||||
line:__LINE__ \
|
||||
tag:atag \
|
||||
format:(frmt), ##__VA_ARGS__]
|
||||
|
||||
/**
|
||||
* Define the Objective-C and C versions of the macro.
|
||||
* These automatically inject the proper function name for either an objective-c method or c function.
|
||||
*
|
||||
* We also define shorthand versions for asynchronous and synchronous logging.
|
||||
**/
|
||||
|
||||
#define LOG_OBJC_MACRO(async, lvl, flg, ctx, frmt, ...) \
|
||||
LOG_MACRO(async, lvl, flg, ctx, nil, sel_getName(_cmd), frmt, ##__VA_ARGS__)
|
||||
|
||||
#define LOG_C_MACRO(async, lvl, flg, ctx, frmt, ...) \
|
||||
LOG_MACRO(async, lvl, flg, ctx, nil, __FUNCTION__, frmt, ##__VA_ARGS__)
|
||||
|
||||
#define SYNC_LOG_OBJC_MACRO(lvl, flg, ctx, frmt, ...) \
|
||||
LOG_OBJC_MACRO( NO, lvl, flg, ctx, frmt, ##__VA_ARGS__)
|
||||
|
||||
#define ASYNC_LOG_OBJC_MACRO(lvl, flg, ctx, frmt, ...) \
|
||||
LOG_OBJC_MACRO(YES, lvl, flg, ctx, frmt, ##__VA_ARGS__)
|
||||
|
||||
#define SYNC_LOG_C_MACRO(lvl, flg, ctx, frmt, ...) \
|
||||
LOG_C_MACRO( NO, lvl, flg, ctx, frmt, ##__VA_ARGS__)
|
||||
|
||||
#define ASYNC_LOG_C_MACRO(lvl, flg, ctx, frmt, ...) \
|
||||
LOG_C_MACRO(YES, lvl, flg, ctx, frmt, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* Define version of the macro that only execute if the logLevel is above the threshold.
|
||||
* The compiled versions essentially look like this:
|
||||
*
|
||||
* if (logFlagForThisLogMsg & ddLogLevel) { execute log message }
|
||||
*
|
||||
* As shown further below, Lumberjack actually uses a bitmask as opposed to primitive log levels.
|
||||
* This allows for a great amount of flexibility and some pretty advanced fine grained logging techniques.
|
||||
*
|
||||
* Note that when compiler optimizations are enabled (as they are for your release builds),
|
||||
* the log messages above your logging threshold will automatically be compiled out.
|
||||
*
|
||||
* (If the compiler sees ddLogLevel declared as a constant, the compiler simply checks to see if the 'if' statement
|
||||
* would execute, and if not it strips it from the binary.)
|
||||
*
|
||||
* We also define shorthand versions for asynchronous and synchronous logging.
|
||||
**/
|
||||
|
||||
#define LOG_MAYBE(async, lvl, flg, ctx, fnct, frmt, ...) \
|
||||
do { if(lvl & flg) LOG_MACRO(async, lvl, flg, ctx, nil, fnct, frmt, ##__VA_ARGS__); } while(0)
|
||||
|
||||
#define LOG_OBJC_MAYBE(async, lvl, flg, ctx, frmt, ...) \
|
||||
LOG_MAYBE(async, lvl, flg, ctx, sel_getName(_cmd), frmt, ##__VA_ARGS__)
|
||||
|
||||
#define LOG_C_MAYBE(async, lvl, flg, ctx, frmt, ...) \
|
||||
LOG_MAYBE(async, lvl, flg, ctx, __FUNCTION__, frmt, ##__VA_ARGS__)
|
||||
|
||||
#define SYNC_LOG_OBJC_MAYBE(lvl, flg, ctx, frmt, ...) \
|
||||
LOG_OBJC_MAYBE( NO, lvl, flg, ctx, frmt, ##__VA_ARGS__)
|
||||
|
||||
#define ASYNC_LOG_OBJC_MAYBE(lvl, flg, ctx, frmt, ...) \
|
||||
LOG_OBJC_MAYBE(YES, lvl, flg, ctx, frmt, ##__VA_ARGS__)
|
||||
|
||||
#define SYNC_LOG_C_MAYBE(lvl, flg, ctx, frmt, ...) \
|
||||
LOG_C_MAYBE( NO, lvl, flg, ctx, frmt, ##__VA_ARGS__)
|
||||
|
||||
#define ASYNC_LOG_C_MAYBE(lvl, flg, ctx, frmt, ...) \
|
||||
LOG_C_MAYBE(YES, lvl, flg, ctx, frmt, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* Define versions of the macros that also accept tags.
|
||||
*
|
||||
* The DDLogMessage object includes a 'tag' ivar that may be used for a variety of purposes.
|
||||
* It may be used to pass custom information to loggers or formatters.
|
||||
* Or it may be used by 3rd party extensions to the framework.
|
||||
*
|
||||
* Thes macros just make it a little easier to extend logging functionality.
|
||||
**/
|
||||
|
||||
#define LOG_OBJC_TAG_MACRO(async, lvl, flg, ctx, tag, frmt, ...) \
|
||||
LOG_MACRO(async, lvl, flg, ctx, tag, sel_getName(_cmd), frmt, ##__VA_ARGS__)
|
||||
|
||||
#define LOG_C_TAG_MACRO(async, lvl, flg, ctx, tag, frmt, ...) \
|
||||
LOG_MACRO(async, lvl, flg, ctx, tag, __FUNCTION__, frmt, ##__VA_ARGS__)
|
||||
|
||||
#define LOG_TAG_MAYBE(async, lvl, flg, ctx, tag, fnct, frmt, ...) \
|
||||
do { if(lvl & flg) LOG_MACRO(async, lvl, flg, ctx, tag, fnct, frmt, ##__VA_ARGS__); } while(0)
|
||||
|
||||
#define LOG_OBJC_TAG_MAYBE(async, lvl, flg, ctx, tag, frmt, ...) \
|
||||
LOG_TAG_MAYBE(async, lvl, flg, ctx, tag, sel_getName(_cmd), frmt, ##__VA_ARGS__)
|
||||
|
||||
#define LOG_C_TAG_MAYBE(async, lvl, flg, ctx, tag, frmt, ...) \
|
||||
LOG_TAG_MAYBE(async, lvl, flg, ctx, tag, __FUNCTION__, frmt, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* Define the standard options.
|
||||
*
|
||||
* We default to only 4 levels because it makes it easier for beginners
|
||||
* to make the transition to a logging framework.
|
||||
*
|
||||
* More advanced users may choose to completely customize the levels (and level names) to suite their needs.
|
||||
* For more information on this see the "Custom Log Levels" page:
|
||||
* https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomLogLevels
|
||||
*
|
||||
* Advanced users may also notice that we're using a bitmask.
|
||||
* This is to allow for custom fine grained logging:
|
||||
* https://github.com/robbiehanson/CocoaLumberjack/wiki/FineGrainedLogging
|
||||
*
|
||||
* -- Flags --
|
||||
*
|
||||
* Typically you will use the LOG_LEVELS (see below), but the flags may be used directly in certain situations.
|
||||
* For example, say you have a lot of warning log messages, and you wanted to disable them.
|
||||
* However, you still needed to see your error and info log messages.
|
||||
* You could accomplish that with the following:
|
||||
*
|
||||
* static const int ddLogLevel = LOG_FLAG_ERROR | LOG_FLAG_INFO;
|
||||
*
|
||||
* Flags may also be consulted when writing custom log formatters,
|
||||
* as the DDLogMessage class captures the individual flag that caused the log message to fire.
|
||||
*
|
||||
* -- Levels --
|
||||
*
|
||||
* Log levels are simply the proper bitmask of the flags.
|
||||
*
|
||||
* -- Booleans --
|
||||
*
|
||||
* The booleans may be used when your logging code involves more than one line.
|
||||
* For example:
|
||||
*
|
||||
* if (LOG_VERBOSE) {
|
||||
* for (id sprocket in sprockets)
|
||||
* DDLogVerbose(@"sprocket: %@", [sprocket description])
|
||||
* }
|
||||
*
|
||||
* -- Async --
|
||||
*
|
||||
* Defines the default asynchronous options.
|
||||
* The default philosophy for asynchronous logging is very simple:
|
||||
*
|
||||
* Log messages with errors should be executed synchronously.
|
||||
* After all, an error just occurred. The application could be unstable.
|
||||
*
|
||||
* All other log messages, such as debug output, are executed asynchronously.
|
||||
* After all, if it wasn't an error, then it was just informational output,
|
||||
* or something the application was easily able to recover from.
|
||||
*
|
||||
* -- Changes --
|
||||
*
|
||||
* You are strongly discouraged from modifying this file.
|
||||
* If you do, you make it more difficult on yourself to merge future bug fixes and improvements from the project.
|
||||
* Instead, create your own MyLogging.h or ApplicationNameLogging.h or CompanyLogging.h
|
||||
*
|
||||
* For an example of customizing your logging experience, see the "Custom Log Levels" page:
|
||||
* https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomLogLevels
|
||||
**/
|
||||
|
||||
#define LOG_FLAG_ERROR (1 << 0) // 0...0001
|
||||
#define LOG_FLAG_WARN (1 << 1) // 0...0010
|
||||
#define LOG_FLAG_INFO (1 << 2) // 0...0100
|
||||
#define LOG_FLAG_VERBOSE (1 << 3) // 0...1000
|
||||
|
||||
#define LOG_LEVEL_OFF 0
|
||||
#define LOG_LEVEL_ERROR (LOG_FLAG_ERROR) // 0...0001
|
||||
#define LOG_LEVEL_WARN (LOG_FLAG_ERROR | LOG_FLAG_WARN) // 0...0011
|
||||
#define LOG_LEVEL_INFO (LOG_FLAG_ERROR | LOG_FLAG_WARN | LOG_FLAG_INFO) // 0...0111
|
||||
#define LOG_LEVEL_VERBOSE (LOG_FLAG_ERROR | LOG_FLAG_WARN | LOG_FLAG_INFO | LOG_FLAG_VERBOSE) // 0...1111
|
||||
|
||||
#define LOG_ERROR (ddLogLevel & LOG_FLAG_ERROR)
|
||||
#define LOG_WARN (ddLogLevel & LOG_FLAG_WARN)
|
||||
#define LOG_INFO (ddLogLevel & LOG_FLAG_INFO)
|
||||
#define LOG_VERBOSE (ddLogLevel & LOG_FLAG_VERBOSE)
|
||||
|
||||
#define LOG_ASYNC_ENABLED YES
|
||||
|
||||
#define LOG_ASYNC_ERROR ( NO && LOG_ASYNC_ENABLED)
|
||||
#define LOG_ASYNC_WARN (YES && LOG_ASYNC_ENABLED)
|
||||
#define LOG_ASYNC_INFO (YES && LOG_ASYNC_ENABLED)
|
||||
#define LOG_ASYNC_VERBOSE (YES && LOG_ASYNC_ENABLED)
|
||||
|
||||
#define DDLogError(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_ERROR, ddLogLevel, LOG_FLAG_ERROR, 0, frmt, ##__VA_ARGS__)
|
||||
#define DDLogWarn(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_WARN, ddLogLevel, LOG_FLAG_WARN, 0, frmt, ##__VA_ARGS__)
|
||||
#define DDLogInfo(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_INFO, ddLogLevel, LOG_FLAG_INFO, 0, frmt, ##__VA_ARGS__)
|
||||
#define DDLogVerbose(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_VERBOSE, ddLogLevel, LOG_FLAG_VERBOSE, 0, frmt, ##__VA_ARGS__)
|
||||
|
||||
#define DDLogCError(frmt, ...) LOG_C_MAYBE(LOG_ASYNC_ERROR, ddLogLevel, LOG_FLAG_ERROR, 0, frmt, ##__VA_ARGS__)
|
||||
#define DDLogCWarn(frmt, ...) LOG_C_MAYBE(LOG_ASYNC_WARN, ddLogLevel, LOG_FLAG_WARN, 0, frmt, ##__VA_ARGS__)
|
||||
#define DDLogCInfo(frmt, ...) LOG_C_MAYBE(LOG_ASYNC_INFO, ddLogLevel, LOG_FLAG_INFO, 0, frmt, ##__VA_ARGS__)
|
||||
#define DDLogCVerbose(frmt, ...) LOG_C_MAYBE(LOG_ASYNC_VERBOSE, ddLogLevel, LOG_FLAG_VERBOSE, 0, frmt, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* The THIS_FILE macro gives you an NSString of the file name.
|
||||
* For simplicity and clarity, the file name does not include the full path or file extension.
|
||||
*
|
||||
* For example: DDLogWarn(@"%@: Unable to find thingy", THIS_FILE) -> @"MyViewController: Unable to find thingy"
|
||||
**/
|
||||
|
||||
NSString *DDExtractFileNameWithoutExtension(const char *filePath, BOOL copy);
|
||||
|
||||
#define THIS_FILE (DDExtractFileNameWithoutExtension(__FILE__, NO))
|
||||
|
||||
/**
|
||||
* The THIS_METHOD macro gives you the name of the current objective-c method.
|
||||
*
|
||||
* For example: DDLogWarn(@"%@ - Requires non-nil strings") -> @"setMake:model: requires non-nil strings"
|
||||
*
|
||||
* Note: This does NOT work in straight C functions (non objective-c).
|
||||
* Instead you should use the predefined __FUNCTION__ macro.
|
||||
**/
|
||||
|
||||
#define THIS_METHOD NSStringFromSelector(_cmd)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark -
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@interface DDLog : NSObject
|
||||
|
||||
/**
|
||||
* Provides access to the underlying logging queue.
|
||||
* This may be helpful to Logger classes for things like thread synchronization.
|
||||
**/
|
||||
|
||||
+ (dispatch_queue_t)loggingQueue;
|
||||
|
||||
/**
|
||||
* Logging Primitive.
|
||||
*
|
||||
* This method is used by the macros above.
|
||||
* It is suggested you stick with the macros as they're easier to use.
|
||||
**/
|
||||
|
||||
+ (void)log:(BOOL)synchronous
|
||||
level:(int)level
|
||||
flag:(int)flag
|
||||
context:(int)context
|
||||
file:(const char *)file
|
||||
function:(const char *)function
|
||||
line:(int)line
|
||||
tag:(id)tag
|
||||
format:(NSString *)format, ... __attribute__ ((format (__NSString__, 9, 10)));
|
||||
|
||||
/**
|
||||
* Logging Primitive.
|
||||
*
|
||||
* This method can be used if you have a prepared va_list.
|
||||
**/
|
||||
|
||||
+ (void)log:(BOOL)asynchronous
|
||||
level:(int)level
|
||||
flag:(int)flag
|
||||
context:(int)context
|
||||
file:(const char *)file
|
||||
function:(const char *)function
|
||||
line:(int)line
|
||||
tag:(id)tag
|
||||
format:(NSString *)format
|
||||
args:(va_list)argList;
|
||||
|
||||
|
||||
/**
|
||||
* Since logging can be asynchronous, there may be times when you want to flush the logs.
|
||||
* The framework invokes this automatically when the application quits.
|
||||
**/
|
||||
|
||||
+ (void)flushLog;
|
||||
|
||||
/**
|
||||
* Loggers
|
||||
*
|
||||
* If you want your log statements to go somewhere,
|
||||
* you should create and add a logger.
|
||||
**/
|
||||
|
||||
+ (void)addLogger:(id <DDLogger>)logger;
|
||||
+ (void)removeLogger:(id <DDLogger>)logger;
|
||||
|
||||
+ (void)removeAllLoggers;
|
||||
|
||||
/**
|
||||
* Registered Dynamic Logging
|
||||
*
|
||||
* These methods allow you to obtain a list of classes that are using registered dynamic logging,
|
||||
* and also provides methods to get and set their log level during run time.
|
||||
**/
|
||||
|
||||
+ (NSArray *)registeredClasses;
|
||||
+ (NSArray *)registeredClassNames;
|
||||
|
||||
+ (int)logLevelForClass:(Class)aClass;
|
||||
+ (int)logLevelForClassWithName:(NSString *)aClassName;
|
||||
|
||||
+ (void)setLogLevel:(int)logLevel forClass:(Class)aClass;
|
||||
+ (void)setLogLevel:(int)logLevel forClassWithName:(NSString *)aClassName;
|
||||
|
||||
@end
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark -
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@protocol DDLogger <NSObject>
|
||||
@required
|
||||
|
||||
- (void)logMessage:(DDLogMessage *)logMessage;
|
||||
|
||||
/**
|
||||
* Formatters may optionally be added to any logger.
|
||||
*
|
||||
* If no formatter is set, the logger simply logs the message as it is given in logMessage,
|
||||
* or it may use its own built in formatting style.
|
||||
**/
|
||||
- (id <DDLogFormatter>)logFormatter;
|
||||
- (void)setLogFormatter:(id <DDLogFormatter>)formatter;
|
||||
|
||||
@optional
|
||||
|
||||
/**
|
||||
* Since logging is asynchronous, adding and removing loggers is also asynchronous.
|
||||
* In other words, the loggers are added and removed at appropriate times with regards to log messages.
|
||||
*
|
||||
* - Loggers will not receive log messages that were executed prior to when they were added.
|
||||
* - Loggers will not receive log messages that were executed after they were removed.
|
||||
*
|
||||
* These methods are executed in the logging thread/queue.
|
||||
* This is the same thread/queue that will execute every logMessage: invocation.
|
||||
* Loggers may use these methods for thread synchronization or other setup/teardown tasks.
|
||||
**/
|
||||
- (void)didAddLogger;
|
||||
- (void)willRemoveLogger;
|
||||
|
||||
/**
|
||||
* Some loggers may buffer IO for optimization purposes.
|
||||
* For example, a database logger may only save occasionaly as the disk IO is slow.
|
||||
* In such loggers, this method should be implemented to flush any pending IO.
|
||||
*
|
||||
* This allows invocations of DDLog's flushLog method to be propogated to loggers that need it.
|
||||
*
|
||||
* Note that DDLog's flushLog method is invoked automatically when the application quits,
|
||||
* and it may be also invoked manually by the developer prior to application crashes, or other such reasons.
|
||||
**/
|
||||
- (void)flush;
|
||||
|
||||
/**
|
||||
* Each logger is executed concurrently with respect to the other loggers.
|
||||
* Thus, a dedicated dispatch queue is used for each logger.
|
||||
* Logger implementations may optionally choose to provide their own dispatch queue.
|
||||
**/
|
||||
- (dispatch_queue_t)loggerQueue;
|
||||
|
||||
/**
|
||||
* If the logger implementation does not choose to provide its own queue,
|
||||
* one will automatically be created for it.
|
||||
* The created queue will receive its name from this method.
|
||||
* This may be helpful for debugging or profiling reasons.
|
||||
**/
|
||||
- (NSString *)loggerName;
|
||||
|
||||
@end
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark -
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@protocol DDLogFormatter <NSObject>
|
||||
@required
|
||||
|
||||
/**
|
||||
* Formatters may optionally be added to any logger.
|
||||
* This allows for increased flexibility in the logging environment.
|
||||
* For example, log messages for log files may be formatted differently than log messages for the console.
|
||||
*
|
||||
* For more information about formatters, see the "Custom Formatters" page:
|
||||
* https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomFormatters
|
||||
*
|
||||
* The formatter may also optionally filter the log message by returning nil,
|
||||
* in which case the logger will not log the message.
|
||||
**/
|
||||
- (NSString *)formatLogMessage:(DDLogMessage *)logMessage;
|
||||
|
||||
@optional
|
||||
|
||||
/**
|
||||
* A single formatter instance can be added to multiple loggers.
|
||||
* These methods provides hooks to notify the formatter of when it's added/removed.
|
||||
*
|
||||
* This is primarily for thread-safety.
|
||||
* If a formatter is explicitly not thread-safe, it may wish to throw an exception if added to multiple loggers.
|
||||
* Or if a formatter has potentially thread-unsafe code (e.g. NSDateFormatter),
|
||||
* it could possibly use these hooks to switch to thread-safe versions of the code.
|
||||
**/
|
||||
- (void)didAddToLogger:(id <DDLogger>)logger;
|
||||
- (void)willRemoveFromLogger:(id <DDLogger>)logger;
|
||||
|
||||
@end
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark -
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@protocol DDRegisteredDynamicLogging
|
||||
|
||||
/**
|
||||
* Implement these methods to allow a file's log level to be managed from a central location.
|
||||
*
|
||||
* This is useful if you'd like to be able to change log levels for various parts
|
||||
* of your code from within the running application.
|
||||
*
|
||||
* Imagine pulling up the settings for your application,
|
||||
* and being able to configure the logging level on a per file basis.
|
||||
*
|
||||
* The implementation can be very straight-forward:
|
||||
*
|
||||
* + (int)ddLogLevel
|
||||
* {
|
||||
* return ddLogLevel;
|
||||
* }
|
||||
*
|
||||
* + (void)ddSetLogLevel:(int)logLevel
|
||||
* {
|
||||
* ddLogLevel = logLevel;
|
||||
* }
|
||||
**/
|
||||
|
||||
+ (int)ddLogLevel;
|
||||
+ (void)ddSetLogLevel:(int)logLevel;
|
||||
|
||||
@end
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark -
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The DDLogMessage class encapsulates information about the log message.
|
||||
* If you write custom loggers or formatters, you will be dealing with objects of this class.
|
||||
**/
|
||||
|
||||
typedef NS_OPTIONS(NSUInteger, DDLogMessageOptions)
|
||||
{
|
||||
DDLogMessageCopyFile = 1 << 0,
|
||||
DDLogMessageCopyFunction = 1 << 1,
|
||||
};
|
||||
|
||||
@interface DDLogMessage : NSObject
|
||||
{
|
||||
|
||||
// The public variables below can be accessed directly (for speed).
|
||||
// For example: logMessage->logLevel
|
||||
|
||||
@public
|
||||
int logLevel;
|
||||
int logFlag;
|
||||
int logContext;
|
||||
NSString *logMsg;
|
||||
NSDate *timestamp;
|
||||
char *file;
|
||||
char *function;
|
||||
int lineNumber;
|
||||
mach_port_t machThreadID;
|
||||
char *queueLabel;
|
||||
NSString *threadName;
|
||||
|
||||
// For 3rd party extensions to the framework, where flags and contexts aren't enough.
|
||||
id tag;
|
||||
|
||||
// For 3rd party extensions that manually create DDLogMessage instances.
|
||||
DDLogMessageOptions options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard init method for a log message object.
|
||||
* Used by the logging primitives. (And the macros use the logging primitives.)
|
||||
*
|
||||
* If you find need to manually create logMessage objects, there is one thing you should be aware of:
|
||||
*
|
||||
* If no flags are passed, the method expects the file and function parameters to be string literals.
|
||||
* That is, it expects the given strings to exist for the duration of the object's lifetime,
|
||||
* and it expects the given strings to be immutable.
|
||||
* In other words, it does not copy these strings, it simply points to them.
|
||||
* This is due to the fact that __FILE__ and __FUNCTION__ are usually used to specify these parameters,
|
||||
* so it makes sense to optimize and skip the unnecessary allocations.
|
||||
* However, if you need them to be copied you may use the options parameter to specify this.
|
||||
* Options is a bitmask which supports DDLogMessageCopyFile and DDLogMessageCopyFunction.
|
||||
**/
|
||||
- (instancetype)initWithLogMsg:(NSString *)logMsg
|
||||
level:(int)logLevel
|
||||
flag:(int)logFlag
|
||||
context:(int)logContext
|
||||
file:(const char *)file
|
||||
function:(const char *)function
|
||||
line:(int)line
|
||||
tag:(id)tag
|
||||
options:(DDLogMessageOptions)optionsMask;
|
||||
|
||||
/**
|
||||
* Returns the threadID as it appears in NSLog.
|
||||
* That is, it is a hexadecimal value which is calculated from the machThreadID.
|
||||
**/
|
||||
@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *threadID;
|
||||
|
||||
/**
|
||||
* Convenience property to get just the file name, as the file variable is generally the full file path.
|
||||
* This method does not include the file extension, which is generally unwanted for logging purposes.
|
||||
**/
|
||||
@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *fileName;
|
||||
|
||||
/**
|
||||
* Returns the function variable in NSString form.
|
||||
**/
|
||||
@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSString *methodName;
|
||||
|
||||
@end
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma mark -
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The DDLogger protocol specifies that an optional formatter can be added to a logger.
|
||||
* Most (but not all) loggers will want to support formatters.
|
||||
*
|
||||
* However, writting getters and setters in a thread safe manner,
|
||||
* while still maintaining maximum speed for the logging process, is a difficult task.
|
||||
*
|
||||
* To do it right, the implementation of the getter/setter has strict requiremenets:
|
||||
* - Must NOT require the logMessage method to acquire a lock.
|
||||
* - Must NOT require the logMessage method to access an atomic property (also a lock of sorts).
|
||||
*
|
||||
* To simplify things, an abstract logger is provided that implements the getter and setter.
|
||||
*
|
||||
* Logger implementations may simply extend this class,
|
||||
* and they can ACCESS THE FORMATTER VARIABLE DIRECTLY from within their logMessage method!
|
||||
**/
|
||||
|
||||
@interface DDAbstractLogger : NSObject <DDLogger>
|
||||
{
|
||||
id <DDLogFormatter> formatter;
|
||||
|
||||
dispatch_queue_t loggerQueue;
|
||||
}
|
||||
|
||||
@property (NS_NONATOMIC_IOSONLY, strong) id<DDLogFormatter> logFormatter;
|
||||
|
||||
@end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,167 +0,0 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#if TARGET_OS_IPHONE
|
||||
#import <UIKit/UIColor.h>
|
||||
#else
|
||||
#import <AppKit/NSColor.h>
|
||||
#endif
|
||||
|
||||
#import "DDLog.h"
|
||||
|
||||
/**
|
||||
* Welcome to Cocoa Lumberjack!
|
||||
*
|
||||
* The project page has a wealth of documentation if you have any questions.
|
||||
* https://github.com/robbiehanson/CocoaLumberjack
|
||||
*
|
||||
* If you're new to the project you may wish to read the "Getting Started" wiki.
|
||||
* https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
|
||||
*
|
||||
*
|
||||
* This class provides a logger for Terminal output or Xcode console output,
|
||||
* depending on where you are running your code.
|
||||
*
|
||||
* As described in the "Getting Started" page,
|
||||
* the traditional NSLog() function directs it's output to two places:
|
||||
*
|
||||
* - Apple System Log (so it shows up in Console.app)
|
||||
* - StdErr (if stderr is a TTY, so log statements show up in Xcode console)
|
||||
*
|
||||
* To duplicate NSLog() functionality you can simply add this logger and an asl logger.
|
||||
* However, if you instead choose to use file logging (for faster performance),
|
||||
* you may choose to use only a file logger and a tty logger.
|
||||
**/
|
||||
|
||||
@interface DDTTYLogger : DDAbstractLogger <DDLogger>
|
||||
{
|
||||
NSCalendar *calendar;
|
||||
NSUInteger calendarUnitFlags;
|
||||
|
||||
NSString *appName;
|
||||
char *app;
|
||||
size_t appLen;
|
||||
|
||||
NSString *processID;
|
||||
char *pid;
|
||||
size_t pidLen;
|
||||
|
||||
BOOL colorsEnabled;
|
||||
NSMutableArray *colorProfilesArray;
|
||||
NSMutableDictionary *colorProfilesDict;
|
||||
}
|
||||
|
||||
+ (DDTTYLogger *)sharedInstance;
|
||||
|
||||
/* Inherited from the DDLogger protocol:
|
||||
*
|
||||
* Formatters may optionally be added to any logger.
|
||||
*
|
||||
* If no formatter is set, the logger simply logs the message as it is given in logMessage,
|
||||
* or it may use its own built in formatting style.
|
||||
*
|
||||
* More information about formatters can be found here:
|
||||
* https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomFormatters
|
||||
*
|
||||
* The actual implementation of these methods is inherited from DDAbstractLogger.
|
||||
|
||||
- (id <DDLogFormatter>)logFormatter;
|
||||
- (void)setLogFormatter:(id <DDLogFormatter>)formatter;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* Want to use different colors for different log levels?
|
||||
* Enable this property.
|
||||
*
|
||||
* If you run the application via the Terminal (not Xcode),
|
||||
* the logger will map colors to xterm-256color or xterm-color (if available).
|
||||
*
|
||||
* Xcode does NOT natively support colors in the Xcode debugging console.
|
||||
* You'll need to install the XcodeColors plugin to see colors in the Xcode console.
|
||||
* https://github.com/robbiehanson/XcodeColors
|
||||
*
|
||||
* The default value if NO.
|
||||
**/
|
||||
@property (readwrite, assign) BOOL colorsEnabled;
|
||||
|
||||
/**
|
||||
* The default color set (foregroundColor, backgroundColor) is:
|
||||
*
|
||||
* - LOG_FLAG_ERROR = (red, nil)
|
||||
* - LOG_FLAG_WARN = (orange, nil)
|
||||
*
|
||||
* You can customize the colors however you see fit.
|
||||
* Please note that you are passing a flag, NOT a level.
|
||||
*
|
||||
* GOOD : [ttyLogger setForegroundColor:pink backgroundColor:nil forFlag:LOG_FLAG_INFO]; // <- Good :)
|
||||
* BAD : [ttyLogger setForegroundColor:pink backgroundColor:nil forFlag:LOG_LEVEL_INFO]; // <- BAD! :(
|
||||
*
|
||||
* LOG_FLAG_INFO = 0...00100
|
||||
* LOG_LEVEL_INFO = 0...00111 <- Would match LOG_FLAG_INFO and LOG_FLAG_WARN and LOG_FLAG_ERROR
|
||||
*
|
||||
* If you run the application within Xcode, then the XcodeColors plugin is required.
|
||||
*
|
||||
* If you run the application from a shell, then DDTTYLogger will automatically map the given color to
|
||||
* the closest available color. (xterm-256color or xterm-color which have 256 and 16 supported colors respectively.)
|
||||
*
|
||||
* This method invokes setForegroundColor:backgroundColor:forFlag:context: and passes the default context (0).
|
||||
**/
|
||||
#if TARGET_OS_IPHONE
|
||||
- (void)setForegroundColor:(UIColor *)txtColor backgroundColor:(UIColor *)bgColor forFlag:(int)mask;
|
||||
#else
|
||||
- (void)setForegroundColor:(NSColor *)txtColor backgroundColor:(NSColor *)bgColor forFlag:(int)mask;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Just like setForegroundColor:backgroundColor:flag, but allows you to specify a particular logging context.
|
||||
*
|
||||
* A logging context is often used to identify log messages coming from a 3rd party framework,
|
||||
* although logging context's can be used for many different functions.
|
||||
*
|
||||
* Logging context's are explained in further detail here:
|
||||
* https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomContext
|
||||
**/
|
||||
#if TARGET_OS_IPHONE
|
||||
- (void)setForegroundColor:(UIColor *)txtColor backgroundColor:(UIColor *)bgColor forFlag:(int)mask context:(int)ctxt;
|
||||
#else
|
||||
- (void)setForegroundColor:(NSColor *)txtColor backgroundColor:(NSColor *)bgColor forFlag:(int)mask context:(int)ctxt;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Similar to the methods above, but allows you to map DDLogMessage->tag to a particular color profile.
|
||||
* For example, you could do something like this:
|
||||
*
|
||||
* static NSString *const PurpleTag = @"PurpleTag";
|
||||
*
|
||||
* #define DDLogPurple(frmt, ...) LOG_OBJC_TAG_MACRO(NO, 0, 0, 0, PurpleTag, frmt, ##__VA_ARGS__)
|
||||
*
|
||||
* And then in your applicationDidFinishLaunching, or wherever you configure Lumberjack:
|
||||
*
|
||||
* #if TARGET_OS_IPHONE
|
||||
* UIColor *purple = [UIColor colorWithRed:(64/255.0) green:(0/255.0) blue:(128/255.0) alpha:1.0];
|
||||
* #else
|
||||
* NSColor *purple = [NSColor colorWithCalibratedRed:(64/255.0) green:(0/255.0) blue:(128/255.0) alpha:1.0];
|
||||
*
|
||||
* [[DDTTYLogger sharedInstance] setForegroundColor:purple backgroundColor:nil forTag:PurpleTag];
|
||||
* [DDLog addLogger:[DDTTYLogger sharedInstance]];
|
||||
*
|
||||
* This would essentially give you a straight NSLog replacement that prints in purple:
|
||||
*
|
||||
* DDLogPurple(@"I'm a purple log message!");
|
||||
**/
|
||||
#if TARGET_OS_IPHONE
|
||||
- (void)setForegroundColor:(UIColor *)txtColor backgroundColor:(UIColor *)bgColor forTag:(id <NSCopying>)tag;
|
||||
#else
|
||||
- (void)setForegroundColor:(NSColor *)txtColor backgroundColor:(NSColor *)bgColor forTag:(id <NSCopying>)tag;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Clearing color profiles.
|
||||
**/
|
||||
- (void)clearColorsForFlag:(int)mask;
|
||||
- (void)clearColorsForFlag:(int)mask context:(int)context;
|
||||
- (void)clearColorsForTag:(id <NSCopying>)tag;
|
||||
- (void)clearColorsForAllFlags;
|
||||
- (void)clearColorsForAllTags;
|
||||
- (void)clearAllColors;
|
||||
|
||||
@end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@ static NSDictionary* XCCCappuccinoProjectDefaultSettings;
|
||||
static NSString * const XCCSlashReplacement = @"::";
|
||||
|
||||
static NSPredicate * XCCDirectoriesToIgnorePredicate = nil;
|
||||
static NSString * const XCCDirectoriesToIgnorePattern = @"^(?:Build|F(?:rameworks|oundation)|AppKit|Objective-J|(?:Browser|CommonJS)\\.environment|Resources|XcodeSupport|.+\\.xcodeproj)$";
|
||||
static NSString * const XCCDirectoriesToIgnorePattern = @"^(?:Build|F(?:rameworks|oundation)|AppKit|Objective-J|(?:Browser|CommonJS)\\.environment|XcodeSupport|.+\\.xcodeproj)$";
|
||||
|
||||
static NSArray *XCCCappuccinoProjectDefaultIgnoredPaths = nil;
|
||||
|
||||
@@ -242,7 +242,7 @@ NSString * const XCCCappuccinoProjectLastEventIDKey = @"XCCCappuccinoPro
|
||||
|
||||
if (![self shouldIgnoreDirectoryNamed:filename] && ![self pathMatchesIgnoredPaths:path cappuccinoProjectIgnoredPathPredicates:aCappuccinoProject.ignoredPathPredicates])
|
||||
{
|
||||
DDLogVerbose(@"Watching symlinked directory: %@", path);
|
||||
NSLog(@"Watching symlinked directory: %@", path);
|
||||
|
||||
[pathsToWatch addObject:path];
|
||||
}
|
||||
@@ -393,11 +393,11 @@ NSString * const XCCCappuccinoProjectLastEventIDKey = @"XCCCappuccinoPro
|
||||
NSArray *parsedPaths = [XCCCappuccinoProject parseIgnorePaths:ignoredPatterns basePath:self.projectPath];
|
||||
[self.ignoredPathPredicates addObjectsFromArray:parsedPaths];
|
||||
|
||||
DDLogVerbose(@"Content of xcodecapp-ignorepath correctly updated %@", self.ignoredPathPredicates);
|
||||
NSLog(@"Content of xcodecapp-ignorepath correctly updated %@", self.ignoredPathPredicates);
|
||||
}
|
||||
@catch(NSException *exception)
|
||||
{
|
||||
DDLogVerbose(@"Content of xcodecapp-ignorepath does not math the expected input");
|
||||
NSLog(@"Content of xcodecapp-ignorepath does not math the expected input");
|
||||
self.ignoredPathPredicates = [@[] mutableCopy];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
if (![self _projectPathExists] || self.cappuccinoProject.status == XCCCappuccinoProjectStatusListening)
|
||||
return;
|
||||
|
||||
DDLogInfo(@"Start to listen project: %@", self.cappuccinoProject.projectPath);
|
||||
NSLog(@"Start to listen project: %@", self.cappuccinoProject.projectPath);
|
||||
|
||||
[self _synchronizeXcodeSupport];
|
||||
|
||||
@@ -166,7 +166,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
|
||||
- (void)_synchronizeXcodeSupport
|
||||
{
|
||||
DDLogInfo(@"Synchronize project: %@", self.cappuccinoProject.projectPath);
|
||||
NSLog(@"Synchronize project: %@", self.cappuccinoProject.projectPath);
|
||||
|
||||
[self _reinitializeProjectController];
|
||||
[self _reinitializeTaskLauncher];
|
||||
@@ -202,11 +202,11 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
|
||||
if (projectCompatibilityVersion == nil)
|
||||
{
|
||||
DDLogVerbose(@"No compatibility version in project");
|
||||
NSLog(@"No compatibility version in project");
|
||||
return NO;
|
||||
}
|
||||
|
||||
DDLogVerbose(@"XcodeCapp/project compatibility version: %0.1f/%0.1f", projectCompatibilityVersion.doubleValue, appCompatibilityVersion);
|
||||
NSLog(@"XcodeCapp/project compatibility version: %0.1f/%0.1f", projectCompatibilityVersion.doubleValue, appCompatibilityVersion);
|
||||
|
||||
return projectCompatibilityVersion.doubleValue >= appCompatibilityVersion;
|
||||
}
|
||||
@@ -227,7 +227,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
|
||||
[content writeToFile:pbxPath atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
||||
|
||||
DDLogInfo(@"Xcode support project created at: %@", self.cappuccinoProject.XcodeProjectPath);
|
||||
NSLog(@"Xcode support project created at: %@", self.cappuccinoProject.XcodeProjectPath);
|
||||
}
|
||||
|
||||
- (void)_removeXcodeProject
|
||||
@@ -246,7 +246,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
|
||||
[self.cappuccinoProject saveSettings];
|
||||
|
||||
DDLogInfo(@".XcodeSupport directory created at: %@", self.cappuccinoProject.supportPath);
|
||||
NSLog(@".XcodeSupport directory created at: %@", self.cappuccinoProject.supportPath);
|
||||
}
|
||||
|
||||
- (void)_removeXcodeSupportDirectory
|
||||
@@ -311,7 +311,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
|
||||
- (void)_updateXcodeSupportFilesWithModifiedPaths:(NSArray *)modifiedPaths
|
||||
{
|
||||
DDLogVerbose(@"Modified files: %@", modifiedPaths);
|
||||
NSLog(@"Modified files: %@", modifiedPaths);
|
||||
|
||||
for (NSString *path in modifiedPaths)
|
||||
{
|
||||
@@ -328,7 +328,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
|
||||
- (void)_updateXcodeSupportFilesWithRenamedDirectories:(NSArray *)directories
|
||||
{
|
||||
DDLogVerbose(@"Renamed directories: %@", directories);
|
||||
NSLog(@"Renamed directories: %@", directories);
|
||||
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
|
||||
@@ -851,7 +851,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
FSEventStreamScheduleWithRunLoop(self->stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
|
||||
FSEventStreamStart(self->stream);
|
||||
|
||||
DDLogVerbose(@"FSEventStream started for paths: %@", pathsToWatch);
|
||||
NSLog(@"FSEventStream started for paths: %@", pathsToWatch);
|
||||
}
|
||||
|
||||
- (void)_stopFSEventStream
|
||||
@@ -874,7 +874,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
|
||||
self->stream = NULL;
|
||||
|
||||
DDLogVerbose(@"FSEventStream stopped");
|
||||
NSLog(@"FSEventStream stopped");
|
||||
}
|
||||
|
||||
- (void)_handleFSEventsWithPaths:(NSArray *)paths flags:(const FSEventStreamEventFlags[])eventFlags ids:(const FSEventStreamEventId[])eventIds
|
||||
@@ -895,7 +895,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
|
||||
if (rootChanged || needRescan)
|
||||
{
|
||||
DDLogVerbose(@"Watched path changed: %@", path);
|
||||
NSLog(@"Watched path changed: %@", path);
|
||||
|
||||
[self _handleProjectPathChange:path];
|
||||
return;
|
||||
@@ -905,7 +905,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
|
||||
if (isHistoryDoneSentinalEvent)
|
||||
{
|
||||
DDLogVerbose(@"History done sentinal event");
|
||||
NSLog(@"History done sentinal event");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -913,7 +913,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
|
||||
if (isMountEvent)
|
||||
{
|
||||
DDLogVerbose(@"Volume %@: %@", (flags & kFSEventStreamEventFlagMount) ? @"mounted" : @"unmounted", path);
|
||||
NSLog(@"Volume %@: %@", (flags & kFSEventStreamEventFlagMount) ? @"mounted" : @"unmounted", path);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -936,7 +936,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
![XCCCappuccinoProject shouldIgnoreDirectoryNamed:path.lastPathComponent] &&
|
||||
![XCCCappuccinoProject pathMatchesIgnoredPaths:path cappuccinoProjectIgnoredPathPredicates:self.cappuccinoProject.ignoredPathPredicates])
|
||||
{
|
||||
DDLogVerbose(@"Renamed directory: %@", path);
|
||||
NSLog(@"Renamed directory: %@", path);
|
||||
|
||||
[renamedDirectories addObject:path];
|
||||
}
|
||||
@@ -947,7 +947,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
(created || modified || renamed || removed || inodeMetaModified) &&
|
||||
[XCCCappuccinoProject isSourceFile:path cappuccinoProject:self.cappuccinoProject])
|
||||
{
|
||||
DDLogVerbose(@"FSEvent accepted: %@ (%@)", path, [XCCFSEventLogUtils dumpFSEventFlags:flags]);
|
||||
NSLog(@"FSEvent accepted: %@ (%@)", path, [XCCFSEventLogUtils dumpFSEventFlags:flags]);
|
||||
|
||||
if ([fm fileExistsAtPath:path])
|
||||
{
|
||||
@@ -973,7 +973,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
}
|
||||
else if ((isFile || isSymlink) && (renamed || removed) && !(modified || created) && [XCCCappuccinoProject isCibFile:path])
|
||||
{
|
||||
DDLogVerbose(@"FSEvent accepted: %@ (%@)", path, [XCCFSEventLogUtils dumpFSEventFlags:flags]);
|
||||
NSLog(@"FSEvent accepted: %@ (%@)", path, [XCCFSEventLogUtils dumpFSEventFlags:flags]);
|
||||
|
||||
// If a cib is deleted, mark its xib as needing update so the cib is regenerated
|
||||
NSString *xibPath = [path.stringByDeletingPathExtension stringByAppendingPathExtension:@"xib"];
|
||||
@@ -988,7 +988,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
(created || modified || renamed || removed || inodeMetaModified) &&
|
||||
[XCCCappuccinoProject isXCCIgnoreFile:path cappuccinoProject:self.cappuccinoProject])
|
||||
{
|
||||
DDLogVerbose(@"FSEvent accepted: %@ (%@)", path, [XCCFSEventLogUtils dumpFSEventFlags:flags]);
|
||||
NSLog(@"FSEvent accepted: %@ (%@)", path, [XCCFSEventLogUtils dumpFSEventFlags:flags]);
|
||||
|
||||
[self.cappuccinoProject reloadXcodeCappIgnoreFile];
|
||||
}
|
||||
@@ -1137,7 +1137,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
|
||||
- (void)reinitializeProjectFromSettings
|
||||
{
|
||||
DDLogVerbose(@"Saving Cappuccino configuration project %@", self.cappuccinoProject.projectPath);
|
||||
NSLog(@"Saving Cappuccino configuration project %@", self.cappuccinoProject.projectPath);
|
||||
|
||||
[self _cancelAllProjectRelatedOperations];
|
||||
[self.cappuccinoProject saveSettings];
|
||||
@@ -1152,7 +1152,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
if (previousStatus == XCCCappuccinoProjectStatusListening)
|
||||
[self _startListeningToProject];
|
||||
|
||||
DDLogVerbose(@"Cappuccino configuration project %@ has been saved", self.cappuccinoProject.projectPath);
|
||||
NSLog(@"Cappuccino configuration project %@ has been saved", self.cappuccinoProject.projectPath);
|
||||
}
|
||||
|
||||
- (void)applicationIsClosing
|
||||
@@ -1199,7 +1199,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
|
||||
|
||||
if (exists && isDirectory)
|
||||
{
|
||||
DDLogVerbose(@"Opening Xcode project at: %@", self.cappuccinoProject.XcodeProjectPath);
|
||||
NSLog(@"Opening Xcode project at: %@", self.cappuccinoProject.XcodeProjectPath);
|
||||
|
||||
isOpened = [[NSWorkspace sharedWorkspace] openFile:self.cappuccinoProject.XcodeProjectPath];
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ static NSColor * XCCCappuccinoProjectDataViewColorError;
|
||||
self->boxStatus.fillColor = XCCCappuccinoProjectDataViewColorStopped;
|
||||
self->buttonSwitchStatus.image = self.backgroundStyle == NSBackgroundStyleDark ? [NSImage imageNamed:@"run-white"] : [NSImage imageNamed:@"run"];
|
||||
self->operationsProgressIndicator.hidden = YES;
|
||||
[self->operationsProgressIndicator stopAnimation:self];
|
||||
break;
|
||||
|
||||
case XCCCappuccinoProjectStatusListening:
|
||||
@@ -103,6 +104,7 @@ static NSColor * XCCCappuccinoProjectDataViewColorError;
|
||||
{
|
||||
self->operationsProgressIndicator.hidden = YES;
|
||||
[self->operationsProgressIndicator setNeedsDisplay:YES];
|
||||
[self->operationsProgressIndicator stopAnimation:self];
|
||||
}
|
||||
else if (self.controller.operationsTotal <= 4)
|
||||
{
|
||||
@@ -115,6 +117,7 @@ static NSColor * XCCCappuccinoProjectDataViewColorError;
|
||||
self->operationsProgressIndicator.hidden = NO;
|
||||
self->operationsProgressIndicator.indeterminate = NO;
|
||||
self->operationsProgressIndicator.currentValue = self.controller.operationsProgress;
|
||||
[self->operationsProgressIndicator startAnimation:self];
|
||||
[self->operationsProgressIndicator setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
|
||||
@@ -125,13 +125,13 @@
|
||||
|
||||
- (void)_restoreLastSelectedProject
|
||||
{
|
||||
DDLogVerbose(@"Start : selecting last selected project");
|
||||
NSLog(@"Start : selecting last selected project");
|
||||
|
||||
NSString *lastSelectedProjectPath = [[NSUserDefaults standardUserDefaults] valueForKey:XCCUserDefaultsSelectedProjectPath];
|
||||
|
||||
[self _selectCappuccinoProjectControllerWithPath:lastSelectedProjectPath];
|
||||
|
||||
DDLogVerbose(@"Stop : selecting last selected project");
|
||||
NSLog(@"Stop : selecting last selected project");
|
||||
}
|
||||
|
||||
- (void)_selectCappuccinoProjectControllerWithPath:(NSString*)aCappuccinoProjectPath
|
||||
@@ -155,7 +155,7 @@
|
||||
|
||||
- (void)_restoreManagedProjects
|
||||
{
|
||||
DDLogVerbose(@"restore managed projects");
|
||||
NSLog(@"restore managed projects");
|
||||
self.cappuccinoProjectControllers = [@[] mutableCopy];
|
||||
|
||||
NSArray *projectHistory = [[NSUserDefaults standardUserDefaults] arrayForKey:XCCUserDefaultsManagedProjects];
|
||||
@@ -164,11 +164,11 @@
|
||||
|
||||
for (NSString *path in projectHistory)
|
||||
{
|
||||
DDLogVerbose(@"Checking previously managed project at path: %@", path);
|
||||
NSLog(@"Checking previously managed project at path: %@", path);
|
||||
if (![fm fileExistsAtPath:path isDirectory:nil])
|
||||
{
|
||||
[missingProjects addObject:path];
|
||||
DDLogVerbose(@"Not found: project at path: %@", path);
|
||||
NSLog(@"Not found: project at path: %@", path);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@
|
||||
[controller switchProjectListeningStatus:self];
|
||||
}
|
||||
|
||||
DDLogVerbose(@"managed projects restored");
|
||||
NSLog(@"managed projects restored");
|
||||
}
|
||||
|
||||
- (void)_saveSelectedProject
|
||||
|
||||
@@ -69,7 +69,7 @@ NSString * const XCCPBXOperationDidEndNotification = @"XCCPbxCreationDidEndNotif
|
||||
{
|
||||
[self dispatchNotificationName:XCCPBXOperationDidStartNotification];
|
||||
|
||||
DDLogVerbose(@"Pbx creation started: %@", self.cappuccinoProject.projectPath);
|
||||
NSLog(@"Pbx creation started: %@", self.cappuccinoProject.projectPath);
|
||||
|
||||
@try
|
||||
{
|
||||
@@ -88,7 +88,7 @@ NSString * const XCCPBXOperationDidEndNotification = @"XCCPbxCreationDidEndNotif
|
||||
shouldLaunchTask = YES;
|
||||
}
|
||||
|
||||
DDLogVerbose(@"PBX: path to %@ : %@", action, paths);
|
||||
NSLog(@"PBX: path to %@ : %@", action, paths);
|
||||
}
|
||||
|
||||
if (shouldLaunchTask)
|
||||
@@ -109,7 +109,7 @@ NSString * const XCCPBXOperationDidEndNotification = @"XCCPbxCreationDidEndNotif
|
||||
@catch (NSException *exception)
|
||||
{
|
||||
[self dispatchNotificationName:XCCPbxCreationGenerateErrorNotification];
|
||||
DDLogVerbose(@"Pbx creation failed: %@", exception);
|
||||
NSLog(@"Pbx creation failed: %@", exception);
|
||||
}
|
||||
@finally
|
||||
{
|
||||
@@ -117,10 +117,11 @@ NSString * const XCCPBXOperationDidEndNotification = @"XCCPbxCreationDidEndNotif
|
||||
|
||||
self.completionBlock = ^{
|
||||
[weakOperation dispatchNotificationName:XCCPBXOperationDidEndNotification];
|
||||
[weakOperation setCompletionBlock:nil];
|
||||
};
|
||||
}
|
||||
|
||||
DDLogVerbose(@"Pbx creation ended: %@", self.cappuccinoProject.projectPath);
|
||||
NSLog(@"Pbx creation ended: %@", self.cappuccinoProject.projectPath);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -91,7 +91,7 @@ NSString * const XCCNib2CibDidEndNotification = @"XCCNib2C
|
||||
|
||||
- (NSDictionary*)_launchTaskWithCommand:(NSString*)aCommand arguments:(NSArray*)arguments
|
||||
{
|
||||
DDLogVerbose(@"Running processing task: %@ on file: %@", aCommand, self.sourcePath);
|
||||
NSLog(@"Running processing task: %@ on file: %@", aCommand, self.sourcePath);
|
||||
|
||||
self->task = [self->taskLauncher taskWithCommand:aCommand arguments:arguments];
|
||||
|
||||
@@ -184,7 +184,7 @@ NSString * const XCCNib2CibDidEndNotification = @"XCCNib2C
|
||||
|
||||
- (void)main
|
||||
{
|
||||
DDLogVerbose(@"Conversion started: %@", self.sourcePath);
|
||||
NSLog(@"Conversion started: %@", self.sourcePath);
|
||||
|
||||
[self dispatchNotificationName:XCCConversionDidStartNotification];
|
||||
|
||||
@@ -211,7 +211,7 @@ NSString * const XCCNib2CibDidEndNotification = @"XCCNib2C
|
||||
}
|
||||
@catch (NSException *exception)
|
||||
{
|
||||
DDLogVerbose(@"Conversion failed: %@", exception);
|
||||
NSLog(@"Conversion failed: %@", exception);
|
||||
}
|
||||
@finally
|
||||
{
|
||||
@@ -219,10 +219,11 @@ NSString * const XCCNib2CibDidEndNotification = @"XCCNib2C
|
||||
|
||||
self.completionBlock = ^{
|
||||
[weakOperation dispatchNotificationName:XCCConversionDidEndNotification];
|
||||
[weakOperation setCompletionBlock:nil];
|
||||
};
|
||||
}
|
||||
|
||||
DDLogVerbose(@"Conversion ended: %@", self.sourcePath);
|
||||
NSLog(@"Conversion ended: %@", self.sourcePath);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -80,7 +80,7 @@ NSString * const XCCNeedSourceToProjectPathMappingNotification = @"XCCNeedSource
|
||||
{
|
||||
if ([XCCCappuccinoProject shouldIgnoreDirectoryNamed:filename])
|
||||
{
|
||||
DDLogVerbose(@"%@: ignored symlinked directory: %@", self.cappuccinoProject.name, projectRelativePath);
|
||||
NSLog(@"%@: ignored symlinked directory: %@", self.cappuccinoProject.name, projectRelativePath);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ NSString * const XCCNeedSourceToProjectPathMappingNotification = @"XCCNeedSource
|
||||
|
||||
if (![realPath hasPrefix:fullProjectPath] && ![XCCCappuccinoProject pathMatchesIgnoredPaths:fullProjectPath cappuccinoProjectIgnoredPathPredicates:self.cappuccinoProject.ignoredPathPredicates])
|
||||
{
|
||||
DDLogVerbose(@"%@: symlinked directory: %@ -> %@", self.cappuccinoProject.name, projectRelativePath, realPath);
|
||||
NSLog(@"%@: symlinked directory: %@ -> %@", self.cappuccinoProject.name, projectRelativePath, realPath);
|
||||
|
||||
NSMutableDictionary *info = [self operationInformations];
|
||||
info[@"sourcePath"] = realPath;
|
||||
@@ -101,10 +101,10 @@ NSString * const XCCNeedSourceToProjectPathMappingNotification = @"XCCNeedSource
|
||||
[self dispatchNotificationName:XCCNeedSourceToProjectPathMappingNotification userInfo:info];
|
||||
}
|
||||
else
|
||||
DDLogVerbose(@"%@: ignored symlinked directory: %@", self.cappuccinoProject.name, projectRelativePath);
|
||||
NSLog(@"%@: ignored symlinked directory: %@", self.cappuccinoProject.name, projectRelativePath);
|
||||
}
|
||||
|
||||
DDLogVerbose(@"%@: found directory. checking for source files: %@", self.cappuccinoProject.name, filename);
|
||||
NSLog(@"%@: found directory. checking for source files: %@", self.cappuccinoProject.name, filename);
|
||||
|
||||
[sourcePaths addObjectsFromArray:[self _findSourceFilesAtProjectPath:projectRelativePath]];
|
||||
continue;
|
||||
@@ -117,7 +117,7 @@ NSString * const XCCNeedSourceToProjectPathMappingNotification = @"XCCNeedSource
|
||||
|
||||
if ([XCCCappuccinoProject isObjjFile:filename] || [XCCCappuccinoProject isXibFile:filename])
|
||||
{
|
||||
DDLogVerbose(@"%@: found source file: %@", self.cappuccinoProject.name, filename);
|
||||
NSLog(@"%@: found source file: %@", self.cappuccinoProject.name, filename);
|
||||
|
||||
NSString *processedPath;
|
||||
|
||||
@@ -139,7 +139,7 @@ NSString * const XCCNeedSourceToProjectPathMappingNotification = @"XCCNeedSource
|
||||
|
||||
- (void)main
|
||||
{
|
||||
DDLogVerbose(@"Finding source files started");
|
||||
NSLog(@"Finding source files started");
|
||||
|
||||
NSArray *sourcesPaths;
|
||||
|
||||
@@ -151,7 +151,7 @@ NSString * const XCCNeedSourceToProjectPathMappingNotification = @"XCCNeedSource
|
||||
}
|
||||
@catch (NSException *exception)
|
||||
{
|
||||
DDLogVerbose(@"Finding source files failed: %@", exception);
|
||||
NSLog(@"Finding source files failed: %@", exception);
|
||||
}
|
||||
@finally
|
||||
{
|
||||
@@ -160,10 +160,11 @@ NSString * const XCCNeedSourceToProjectPathMappingNotification = @"XCCNeedSource
|
||||
|
||||
self.completionBlock = ^{
|
||||
[weakOperation dispatchNotificationName:XCCSourcesFinderOperationDidEndNotification userInfo:@{@"cappuccinoProject": weakOperation.cappuccinoProject, @"sourcePaths" : weakSourcesPaths}];
|
||||
[weakOperation setCompletionBlock:nil];
|
||||
};
|
||||
}
|
||||
|
||||
DDLogVerbose(@"Finding source files ended");
|
||||
NSLog(@"Finding source files ended");
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
[self.binaryPaths addObject:@"/usr/local/narwhal/bin"];
|
||||
[self.binaryPaths addObject:@"~/narwhal/bin"];
|
||||
|
||||
DDLogError(@"Init task manager with environements %@", self.binaryPaths);
|
||||
NSLog(@"Init task manager with environements %@", self.binaryPaths);
|
||||
|
||||
NSMutableArray *paths = [self.binaryPaths mutableCopy];
|
||||
|
||||
@@ -59,13 +59,13 @@
|
||||
|
||||
if ([taskResult[@"status"] integerValue] != 0)
|
||||
{
|
||||
DDLogError(@"Could not find executable in PATH: %@", self.environment[@"PATH"]);
|
||||
NSLog(@"Could not find executable in PATH: %@", self.environment[@"PATH"]);
|
||||
return NO;
|
||||
}
|
||||
|
||||
self.executablePaths = (NSMutableDictionary*)[NSJSONSerialization JSONObjectWithData:[taskResult[@"response"] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil];
|
||||
|
||||
DDLogVerbose(@"Executable paths: %@", self.executablePaths);
|
||||
NSLog(@"Executable paths: %@", self.executablePaths);
|
||||
|
||||
return YES;
|
||||
}
|
||||
@@ -145,13 +145,13 @@
|
||||
{
|
||||
[aTask launch];
|
||||
|
||||
DDLogVerbose(@"Task launched: %@\n%@", aTask.launchPath, aTask.arguments);
|
||||
NSLog(@"Task launched: %@\n%@", aTask.launchPath, aTask.arguments);
|
||||
|
||||
if (returnType != kTaskReturnTypeNone)
|
||||
{
|
||||
[aTask waitUntilExit];
|
||||
|
||||
DDLogVerbose(@"Task exited: %@\n%@\nExit code:%d", aTask.launchPath, aTask.arguments, aTask.terminationStatus);
|
||||
NSLog(@"Task exited: %@\n%@\nExit code:%d", aTask.launchPath, aTask.arguments, aTask.terminationStatus);
|
||||
|
||||
NSData *data = nil;
|
||||
|
||||
@@ -203,11 +203,11 @@
|
||||
|
||||
[task launch];
|
||||
|
||||
DDLogVerbose(@"Task launched: %@\n%@", launchPath, arguments);
|
||||
NSLog(@"Task launched: %@\n%@", launchPath, arguments);
|
||||
|
||||
[task waitUntilExit];
|
||||
|
||||
DDLogVerbose(@"Task exited: %@:%d", launchPath, task.terminationStatus);
|
||||
NSLog(@"Task exited: %@:%d", launchPath, task.terminationStatus);
|
||||
|
||||
NSNumber *status = @(task.terminationStatus);
|
||||
NSData *data = nil;
|
||||
@@ -230,7 +230,7 @@
|
||||
NSData *data = [notification userInfo][NSFileHandleNotificationDataItem];
|
||||
NSString *string = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
||||
|
||||
DDLogVerbose(@"Jake receive data\n %@", string);
|
||||
NSLog(@"Jake receive data\n %@", string);
|
||||
|
||||
[[notification object] readInBackgroundAndNotify];
|
||||
}
|
||||
@@ -240,7 +240,7 @@
|
||||
NSData *data = [notification userInfo][NSFileHandleNotificationDataItem];
|
||||
NSString *string = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
||||
|
||||
DDLogVerbose(@"Jake receive error\%@", string);
|
||||
NSLog(@"Jake receive error\%@", string);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
extern NSString * const XCCUserDefaultsAutoOpenXcodeProject;
|
||||
extern NSString * const XCCUserDefaultsManagedProjects;
|
||||
extern NSString * const XCCUserDefaultsLogLevel;
|
||||
extern NSString * const XCCUserDefaultsSelectedProjectPath;
|
||||
extern NSString * const XCCUserDefaultsMaxNumberOfConcurrentOperations;
|
||||
|
||||
|
||||
@@ -10,6 +10,5 @@
|
||||
|
||||
NSString * const XCCUserDefaultsAutoOpenXcodeProject = @"XCCUserDefaultsAutoOpenXcodeProject";
|
||||
NSString * const XCCUserDefaultsManagedProjects = @"XCCUserDefaultsManagedProjects";
|
||||
NSString * const XCCUserDefaultsLogLevel = @"XCCUserDefaultsLogLevel";
|
||||
NSString * const XCCUserDefaultsSelectedProjectPath = @"XCCUserDefaultsSelectedProjectPath";
|
||||
NSString * const XCCUserDefaultsMaxNumberOfConcurrentOperations = @"XCCUserDefaultsMaxNumberOfConcurrentOperations";
|
||||
@@ -4,13 +4,4 @@
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "DDLog.h"
|
||||
|
||||
#if DEBUG
|
||||
#import "DDTTYLogger.h"
|
||||
#else
|
||||
#import "DDASLLogger.h"
|
||||
#endif
|
||||
|
||||
#import "DDLogLevel.h"
|
||||
#endif
|
||||
|
||||
@@ -28,12 +28,17 @@ static const char *kCloseXcodeProjectScript =
|
||||
@implementation XcodeProjectCloser
|
||||
|
||||
+ (void)closeXcodeProjectForProject:(NSString *)projectPath
|
||||
{
|
||||
NSString *format = @(kCloseXcodeProjectScript);
|
||||
NSString *source = [NSString stringWithFormat:format, projectPath];
|
||||
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:source];
|
||||
|
||||
[script executeAndReturnError:nil];
|
||||
{
|
||||
NSString *format = @(kCloseXcodeProjectScript);
|
||||
NSString *source = [NSString stringWithFormat:format, projectPath];
|
||||
NSString *arguments = [NSString stringWithFormat:@"-e %@", source];
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
|
||||
[task setLaunchPath:@"/usr/bin/osascript"];
|
||||
[task setArguments:[NSArray arrayWithObjects:arguments, nil]];
|
||||
[task launch];
|
||||
|
||||
NSLog(@"Osascript launched for the project %@", projectPath);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user