I use NSLoger in iOS app, it great, it can show function name, file line, just I also want show the instance of the class information.
eg: class A methods is 'doAction', a instance : A* a = [A alloc];
in method 'doAction':
{
NSLog(@"out this instance information, do not need repeat set the argument [%@]",self );
}
I meaning is that I do not need define the format and the 'self' argument in every NSLog statement....
how to do it ? may I explain clearly and need your help thanks.
so... then I try to add some code as follows:
void LogMessageMe( const char *filename, int lineNumber, const char *functionName,id target, int level, NSString *format, ...)
{
NSString* strTarget = [target description];
va_list args;
va_start(args, format);
LogMessageTo_internal(NULL, filename, lineNumber, functionName, strTarget, level, format, args);
va_end(args);
}
and
#define NSLogMe(...) LogMessageMe( __FILE__, __LINE__, __FUNCTION__, self, 0, __VA_ARGS__)
the call code as follows:
NSLogMe(@"didFinishLaunchingWithOptions");
then output log:
<AppDelegate: 0x906e100> | Main thread | didFinishLaunchingWithOptions
that is really what I want to see... since in a app, many instance was create but that is the same class... if no the identify number, it is hard to trace the target instance ....
but still a issue...
IDE report warning message about the statement:
NSLogMe(@"didFinishLaunchingWithOptions");
"Implicit declaration of function ‘LogMessageMe’ is invalid in C99"
it seem small issue... anyone help ? thanks.