Skip to content

Commit

Permalink
Merge pull request #4 from rsobik/master
Browse files Browse the repository at this point in the history
Enables logging of GCD queue names
  • Loading branch information
robbiehanson committed Sep 16, 2011
2 parents e6df5b3 + ae91036 commit 7a57ad0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Lumberjack/DDLog.h
Expand Up @@ -534,6 +534,9 @@ NSString *ExtractFileNameWithoutExtension(const char *filePath, BOOL copy);
const char *function; const char *function;
int lineNumber; int lineNumber;
mach_port_t machThreadID; mach_port_t machThreadID;
#if GCD_MAYBE_AVAILABLE
char *queueLabel;
#endif


// The private variables below are only calculated if needed. // The private variables below are only calculated if needed.
// You should use the public methods to access this information. // You should use the public methods to access this information.
Expand Down
21 changes: 21 additions & 0 deletions Lumberjack/DDLog.m
Expand Up @@ -1210,6 +1210,19 @@ - (id)initWithLogMsg:(NSString *)msg
timestamp = [[NSDate alloc] init]; timestamp = [[NSDate alloc] init];


machThreadID = pthread_mach_thread_np(pthread_self()); machThreadID = pthread_mach_thread_np(pthread_self());

if (IS_GCD_AVAILABLE)
{
#if GCD_MAYBE_AVAILABLE
const char *label = dispatch_queue_get_label(dispatch_get_current_queue());
if (label) {
size_t labelLength = strlen(label);
queueLabel = malloc(labelLength+1);
strncpy(queueLabel, label, labelLength);
queueLabel[labelLength] = 0;
}
#endif
}
} }
return self; return self;
} }
Expand Down Expand Up @@ -1252,6 +1265,14 @@ - (void)dealloc
[threadID release]; [threadID release];
[fileName release]; [fileName release];
[methodName release]; [methodName release];

if (IS_GCD_AVAILABLE) {
#if GCD_MAYBE_AVAILABLE
if (queueLabel != NULL) {
free(queueLabel);
}
#endif
}


[super dealloc]; [super dealloc];
} }
Expand Down

0 comments on commit 7a57ad0

Please sign in to comment.