adium 4678:6880c201b832: Log line numbers and the dispatch_queue...

commits at adium.im commits at adium.im
Fri Feb 10 22:02:50 UTC 2012


details:	http://hg.adium.im/adium/rev/6880c201b832
revision:	4678:6880c201b832
branch:		(none)
author:		Thijs Alkemade <thijsalkemade at gmail.com>
date:		Fri Feb 10 23:01:26 2012 +0100

Log line numbers and the dispatch_queue's name (if it's not on the main queue) in AILogWithSignature().

diffs (48 lines):

diff -r 72566a9e37c0 -r 6880c201b832 Frameworks/Adium Framework/Source/ESDebugAILog.h
--- a/Frameworks/Adium Framework/Source/ESDebugAILog.h	Thu Feb 09 19:37:36 2012 +0100
+++ b/Frameworks/Adium Framework/Source/ESDebugAILog.h	Fri Feb 10 23:01:26 2012 +0100
@@ -20,9 +20,10 @@
 #define AILog(fmt, args...) do { if (__builtin_expect(AIDebugLoggingEnabled, 0)) AILog_impl(fmt, ##args); } while(0)
 #define AILogWithPrefix(sig, fmt, args...) do { if(__builtin_expect(AIDebugLoggingEnabled, 0)) AILogWithPrefix_impl(sig, fmt, ##args); } while(0)
 #define AILogBacktrace() do { if(__builtin_expect(AIDebugLoggingEnabled, 0)) AILogBacktrace_impl(); } while(0)
-#define AILogWithSignature(fmt, args...) AILogWithPrefix(__PRETTY_FUNCTION__, fmt, ##args);
+#define AILogWithSignature(fmt, args...) AILogWithSignature_impl(__PRETTY_FUNCTION__, __LINE__, fmt, ##args);
 void AIEnableDebugLogging();
 BOOL AIDebugLoggingIsEnabled();
+void AILogWithSignature_impl (const char *function, int line, NSString *format, ...) __attribute__((format(__NSString__, 3, 4)));
 void AILogWithPrefix_impl (const char *signature, NSString *format, ...) __attribute__((format(__NSString__, 2, 3)));
 void AILog_impl (NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
 void AILogBacktrace_impl();
diff -r 72566a9e37c0 -r 6880c201b832 Frameworks/Adium Framework/Source/ESDebugAILog.m
--- a/Frameworks/Adium Framework/Source/ESDebugAILog.m	Thu Feb 09 19:37:36 2012 +0100
+++ b/Frameworks/Adium Framework/Source/ESDebugAILog.m	Fri Feb 10 23:01:26 2012 +0100
@@ -76,6 +76,29 @@
 	va_end(ap); /* clean up when done */
 }
 
+void AILogWithSignature_impl(const char *name, int line, NSString *format, ...) {
+	va_list		ap; /* Points to each unamed argument in turn */
+	NSString	*debugMessage, *actualMessage;
+	const char	*queue = NULL;
+	
+	if (dispatch_get_current_queue() != dispatch_get_main_queue()) {
+		queue = dispatch_queue_get_label(dispatch_get_current_queue());
+	}
+	
+	va_start(ap, format); /* Make ap point to the first unnamed argument */
+	
+	debugMessage = [[NSString alloc] initWithFormat:format
+										  arguments:ap];
+	if (!queue)
+		actualMessage = [NSString stringWithFormat:@"%s:%d: %@", name, line, debugMessage];
+	else
+		actualMessage = [NSString stringWithFormat:@"%s:%d: (on %s) %@", name, line, (queue ?: ""), debugMessage];
+	AIAddDebugMessage(actualMessage);
+	[debugMessage release];
+	
+	va_end(ap); /* clean up when done */
+}
+
 void AILogWithPrefix_impl (const char *prefix, NSString *format, ...) {
 	va_list		ap; /* Points to each unamed argument in turn */
 	NSString	*debugMessage, *actualMessage;




More information about the commits mailing list