Permalink
Browse files

Merge pull request #4 from rsobik/master

Enables logging of GCD queue names
  • Loading branch information...
2 parents e6df5b3 + ae91036 commit 7a57ad0177abc06246214d69750e89b775ff5273 @robbiehanson robbiehanson committed Sep 16, 2011
Showing with 24 additions and 0 deletions.
  1. +3 −0 Lumberjack/DDLog.h
  2. +21 −0 Lumberjack/DDLog.m
View
@@ -534,6 +534,9 @@ NSString *ExtractFileNameWithoutExtension(const char *filePath, BOOL copy);
const char *function;
int lineNumber;
mach_port_t machThreadID;
+#if GCD_MAYBE_AVAILABLE
+ char *queueLabel;
+#endif
// The private variables below are only calculated if needed.
// You should use the public methods to access this information.
View
@@ -1210,6 +1210,19 @@ - (id)initWithLogMsg:(NSString *)msg
timestamp = [[NSDate alloc] init];
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;
}
@@ -1252,6 +1265,14 @@ - (void)dealloc
[threadID release];
[fileName release];
[methodName release];
+
+ if (IS_GCD_AVAILABLE) {
+#if GCD_MAYBE_AVAILABLE
+ if (queueLabel != NULL) {
+ free(queueLabel);
+ }
+#endif
+ }
[super dealloc];
}

0 comments on commit 7a57ad0

Please sign in to comment.