NSString *programName = [NSString stringWithUTF8String:getprogname()]; //get project name
int pid = [[NSProcessInfo processInfo] processIdentifier]; // get process info
NSString *message = [NSString stringWithFormat:@"%@[%d]", programName,pid];
NSLog(@"-----%@",message);
output:
2017-08-25 16:02:05.775792+0800 test[6676:293674] -----xulinmeiTest[6676]