Skip to content

Commit f7de245

Browse files
committed
Merging latest changes from CocoaLumberjack project.
1 parent 4fe8bec commit f7de245

File tree

3 files changed

+1327
-74
lines changed

3 files changed

+1327
-74
lines changed

Vendor/CocoaLumberjack/DDFileLogger.m

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -506,12 +506,12 @@ - (unsigned long long)maximumFileSize
506506
}
507507
else
508508
{
509-
dispatch_queue_t loggingQueue = [DDLog loggingQueue];
510-
NSAssert(currentQueue != loggingQueue, @"Core architecture requirement failure");
509+
dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
510+
NSAssert(currentQueue != globalLoggingQueue, @"Core architecture requirement failure");
511511

512512
__block unsigned long long result;
513513

514-
dispatch_sync(loggingQueue, ^{
514+
dispatch_sync(globalLoggingQueue, ^{
515515
dispatch_sync(loggerQueue, ^{
516516
result = maximumFileSize;
517517
});
@@ -540,10 +540,10 @@ - (void)setMaximumFileSize:(unsigned long long)newMaximumFileSize
540540
}
541541
else
542542
{
543-
dispatch_queue_t loggingQueue = [DDLog loggingQueue];
544-
NSAssert(currentQueue != loggingQueue, @"Core architecture requirement failure");
543+
dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
544+
NSAssert(currentQueue != globalLoggingQueue, @"Core architecture requirement failure");
545545

546-
dispatch_async(loggingQueue, ^{
546+
dispatch_async(globalLoggingQueue, ^{
547547
dispatch_async(loggerQueue, block);
548548
});
549549
}
@@ -564,12 +564,12 @@ - (NSTimeInterval)rollingFrequency
564564
}
565565
else
566566
{
567-
dispatch_queue_t loggingQueue = [DDLog loggingQueue];
568-
NSAssert(currentQueue != loggingQueue, @"Core architecture requirement failure");
567+
dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
568+
NSAssert(currentQueue != globalLoggingQueue, @"Core architecture requirement failure");
569569

570570
__block NSTimeInterval result;
571571

572-
dispatch_sync(loggingQueue, ^{
572+
dispatch_sync(globalLoggingQueue, ^{
573573
dispatch_sync(loggerQueue, ^{
574574
result = rollingFrequency;
575575
});
@@ -598,10 +598,10 @@ - (void)setRollingFrequency:(NSTimeInterval)newRollingFrequency
598598
}
599599
else
600600
{
601-
dispatch_queue_t loggingQueue = [DDLog loggingQueue];
602-
NSAssert(currentQueue != loggingQueue, @"Core architecture requirement failure");
601+
dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
602+
NSAssert(currentQueue != globalLoggingQueue, @"Core architecture requirement failure");
603603

604-
dispatch_async(loggingQueue, ^{
604+
dispatch_async(globalLoggingQueue, ^{
605605
dispatch_async(loggerQueue, block);
606606
});
607607
}
@@ -672,10 +672,10 @@ - (void)rollLogFile
672672
}
673673
else
674674
{
675-
dispatch_queue_t loggingQueue = [DDLog loggingQueue];
676-
NSAssert(currentQueue != loggingQueue, @"Core architecture requirement failure");
675+
dispatch_queue_t globalLoggingQueue = [DDLog loggingQueue];
676+
NSAssert(currentQueue != globalLoggingQueue, @"Core architecture requirement failure");
677677

678-
dispatch_async(loggingQueue, ^{
678+
dispatch_async(globalLoggingQueue, ^{
679679
dispatch_async(loggerQueue, block);
680680
});
681681
}

Vendor/CocoaLumberjack/DDTTYLogger.h

Lines changed: 86 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,99 @@
2828

2929
@interface DDTTYLogger : DDAbstractLogger <DDLogger>
3030
{
31-
BOOL isaTTY;
32-
33-
NSDateFormatter *dateFormatter;
34-
35-
char *app; // Not null terminated
36-
char *pid; // Not null terminated
31+
NSCalendar *calendar;
32+
NSUInteger calendarUnitFlags;
3733

34+
NSString *appName;
35+
char *app;
3836
size_t appLen;
37+
38+
NSString *processID;
39+
char *pid;
3940
size_t pidLen;
41+
42+
BOOL colorsEnabled;
43+
NSMutableArray *colorProfiles;
4044
}
4145

4246
+ (DDTTYLogger *)sharedInstance;
4347

48+
/**
49+
* Want to use different colors for different log levels?
50+
* Enable this property.
51+
*
52+
* If you run the application via the Terminal (not Xcode),
53+
* the logger will map colors to xterm-256color or xterm-color (if available).
54+
*
55+
* Xcode does NOT natively support colors in the Xcode debugging console.
56+
* You'll need to install the XcodeColors plugin to see colors in the Xcode console.
57+
* https://github.com/robbiehanson/XcodeColors
58+
*
59+
* The default value if NO.
60+
**/
61+
@property (readwrite, assign) BOOL colorsEnabled;
62+
63+
/**
64+
* The default color set (foregroundColor, backgroundColor) is:
65+
*
66+
* - LOG_FLAG_ERROR = (red, nil)
67+
* - LOG_FLAG_WARN = (orange, nil)
68+
*
69+
* You can customize the colors however you see fit.
70+
* There are a few things you may need to be aware of:
71+
*
72+
* You are passing a flag, NOT a level.
73+
*
74+
* GOOD : [ttyLogger setForegroundColor:pink backgroundColor:nil forFlag:LOG_FLAG_INFO]; // <- Good :)
75+
* BAD : [ttyLogger setForegroundColor:pink backgroundColor:nil forFlag:LOG_LEVEL_INFO]; // <- BAD! :(
76+
*
77+
* LOG_FLAG_INFO = 0...00100
78+
* LOG_LEVEL_INFO = 0...00111 <- Would match LOG_FLAG_INFO and LOG_FLAG_WARN and LOG_FLAG_ERROR
79+
*
80+
* If you run the application within Xcode, then the XcodeColors plugin is required.
81+
*
82+
* If you run the application from a shell, then DDTTYLogger will automatically try to map the given color to
83+
* the closest available color. (xterm-256color or xterm-color which have 256 and 16 supported colors respectively.)
84+
*
85+
* This method invokes setForegroundColor:backgroundColor:forFlag:context:, and passes the default context (0).
86+
**/
87+
#if TARGET_OS_IPHONE
88+
- (void)setForegroundColor:(UIColor *)txtColor backgroundColor:(UIColor *)bgColor forFlag:(int)mask;
89+
#else
90+
- (void)setForegroundColor:(NSColor *)txtColor backgroundColor:(NSColor *)bgColor forFlag:(int)mask;
91+
#endif
92+
93+
/**
94+
* Allows you to customize the color for a particular flag, within a particular logging context.
95+
*
96+
* A logging context may identify log messages coming from a 3rd party framework.
97+
* Logging context's are explained in further detail here:
98+
* https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomContext
99+
**/
100+
#if TARGET_OS_IPHONE
101+
- (void)setForegroundColor:(UIColor *)txtColor backgroundColor:(UIColor *)bgColor forFlag:(int)mask context:(int)ctxt;
102+
#else
103+
- (void)setForegroundColor:(NSColor *)txtColor backgroundColor:(NSColor *)bgColor forFlag:(int)mask context:(int)ctxt;
104+
#endif
105+
106+
/**
107+
* Clears the color profiles for a particular flag.
108+
*
109+
* This method invokes clearColorsForFlag:context:, and passes the default context (0).
110+
**/
111+
- (void)clearColorsForFlag:(int)mask;
112+
113+
/**
114+
* Clears the color profiles for a particular flag, within a particular logging context.
115+
**/
116+
- (void)clearColorsForFlag:(int)mask context:(int)context;
117+
118+
/**
119+
* Clears all color profiles.
120+
**/
121+
- (void)clearColorsForAllFlags;
122+
123+
44124
// Inherited from DDAbstractLogger
45125

46126
// - (id <DDLogFormatter>)logFormatter;

0 commit comments

Comments
 (0)