Created
November 3, 2016 09:50
-
-
Save iAladdin/3699189daf2a048b3ea965b6595336fb to your computer and use it in GitHub Desktop.
PrettyLog replace NSLog
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 pLog(fmt) prettyLog(fmt,[NSString stringWithFormat:@"%s:%d",__FILE__,__LINE__],__PRETTY_FUNCTION__) | |
NSString * lastFunction = nil; | |
NSString * lastLine = nil; | |
void prettyLog(NSString * string,NSString * fileline,const char * function){ | |
NSString * currentFileLine = fileline; | |
NSString * currentFunction = [NSString stringWithFormat:@"%s",function]; | |
if (lastLine == nil || ![lastLine isEqualToString:currentFileLine]){ | |
printf("\n%s\n",[currentFileLine cStringUsingEncoding:NSUTF8StringEncoding]); | |
lastLine = currentFileLine; | |
} | |
if (lastFunction == nil || ![lastFunction isEqualToString:currentFunction]){ | |
printf("%s\n",[currentFunction cStringUsingEncoding:NSUTF8StringEncoding]); | |
lastFunction = currentFunction; | |
} | |
const char* output = [string cStringUsingEncoding:NSUTF8StringEncoding]; | |
printf("%s\n", output); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment