Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merging latest changes from Lumberjack project

  • Loading branch information...
commit 6e139cee2af33f8dce13bda7a6f8c612ba8cd899 1 parent 97ce46b
@robbiehanson authored
Showing with 54 additions and 30 deletions.
  1. +21 −12 Vendor/CocoaLumberjack/DDLog.h
  2. +33 −18 Vendor/CocoaLumberjack/DDLog.m
View
33 Vendor/CocoaLumberjack/DDLog.h
@@ -240,7 +240,24 @@ NSString *DDExtractFileNameWithoutExtension(const char *filePath, BOOL copy);
function:(const char *)function
line:(int)line
tag:(id)tag
- format:(NSString *)format, ...;
+ 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.
@@ -425,14 +442,6 @@ NSString *DDExtractFileNameWithoutExtension(const char *filePath, BOOL copy);
char *queueLabel;
NSString *threadName;
id tag; // For 3rd party extensions to the framework, where flags and contexts aren't enough.
-
-// The private variables below are only calculated if needed.
-// You should use the public methods to access this information.
-
-@private
- NSString *threadID;
- NSString *fileName;
- NSString *methodName;
}
/**
@@ -457,18 +466,18 @@ NSString *DDExtractFileNameWithoutExtension(const char *filePath, BOOL copy);
* Returns the threadID as it appears in NSLog.
* That is, it is a hexadecimal value which is calculated from the machThreadID.
**/
-@property (nonatomic, readonly) NSString *threadID;
+- (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 (nonatomic, readonly) NSString *fileName;
+- (NSString *)fileName;
/**
* Returns the function variable in NSString form.
**/
-@property (nonatomic, readonly) NSString *methodName;
+- (NSString *)methodName;
@end
View
51 Vendor/CocoaLumberjack/DDLog.m
@@ -286,6 +286,33 @@ + (void)log:(BOOL)asynchronous
}
}
++ (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)args
+{
+ if (format)
+ {
+ NSString *logMsg = [[NSString alloc] initWithFormat:format arguments:args];
+ DDLogMessage *logMessage = [[DDLogMessage alloc] initWithLogMsg:logMsg
+ level:level
+ flag:flag
+ context:context
+ file:file
+ function:function
+ line:line
+ tag:tag];
+
+ [self queueLogMessage:logMessage asynchronously:asynchronous];
+ }
+}
+
+ (void)flushLog
{
dispatch_sync(loggingQueue, ^{ @autoreleasepool {
@@ -806,32 +833,20 @@ - (id)initWithLogMsg:(NSString *)msg
- (NSString *)threadID
{
- if (threadID == nil)
- {
- threadID = [[NSString alloc] initWithFormat:@"%x", machThreadID];
- }
-
- return threadID;
+ return [[NSString alloc] initWithFormat:@"%x", machThreadID];
}
- (NSString *)fileName
{
- if (fileName == nil && file != NULL)
- {
- fileName = DDExtractFileNameWithoutExtension(file, NO);
- }
-
- return fileName;
+ return DDExtractFileNameWithoutExtension(file, NO);
}
- (NSString *)methodName
{
- if (methodName == nil && function != NULL)
- {
- methodName = [[NSString alloc] initWithUTF8String:function];
- }
-
- return methodName;
+ if (function == NULL)
+ return nil;
+ else
+ return [[NSString alloc] initWithUTF8String:function];
}
- (void)dealloc
Please sign in to comment.
Something went wrong with that request. Please try again.