根据代码代码稍作改动。
// 文件 QQLog.h
#import <Foundation/Foundation.h>
#define QQ_DEBUG
@interface QQLog : NSObject {
}
+ (void)file:(char*)sourceFile function:(char*)functionName lineNumber:(int)lineNumber format:(NSString*)format,...;
#define QQLog(args, ...) [UZLog file:__FILE__ function: (char *)__FUNCTION__ lineNumber:__LINE__ format:(args),##__VA_ARGS__]
@end
// 文件QQLog.m
#import "QQLog.h"
@implementation QQLog
+ (void)file:(char *)sourceFile function:(char *)functionName lineNumber:(int)lineNumber format:(NSString*)format, ... {
NSAutoreleasePool *pool = [[NSAutoreleasePoolalloc]init];
va_list ap;
NSString *print, *file, *function;
va_start(ap,format);
file = [[NSStringalloc]initWithBytes: sourceFile length:strlen(sourceFile) encoding:NSUTF8StringEncoding];
function = [NSString stringWithCString: functionName];
print = [[NSString alloc] initWithFormat: format arguments: ap];
va_end(ap);
#ifdef QQ_DEBUG
NSLog(@"%@:%d %@; %@", [filelastPathComponent], lineNumber, function, print);
#endif
[print release];
[file release];
[pool release];
}
@end