Last active
December 29, 2015 07:29
-
-
Save sag333ar/7636866 to your computer and use it in GitHub Desktop.
NSLog without date time stamp, application name, and process id info.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define NSLog(args...) CustomLog(__FILE__, __LINE__, __PRETTY_FUNCTION__, args) | |
static inline void CustomLog(const char *file, int lineNumber, const char *functionName, NSString *format, ...) | |
{ | |
// Type to hold information about variable arguments. | |
va_list ap; | |
// Initialize a variable argument list. | |
va_start (ap, format); | |
// NSLog only adds a newline to the end of the NSLog format if | |
// one is not already there. | |
// Here we are utilizing this feature of NSLog() | |
if (![format hasSuffix: @"\n"]) | |
{ | |
format = [format stringByAppendingString: @"\n"]; | |
} | |
NSString *body = [[NSString alloc] initWithFormat:format arguments:ap]; | |
// End using variable argument list. | |
va_end (ap); | |
NSString *fileName = [[NSString stringWithUTF8String:file] lastPathComponent]; | |
fprintf(stderr, "(%s) (%s:%d) %s", | |
functionName, [fileName UTF8String], | |
lineNumber, [body UTF8String]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment