diff --git a/examples/ios-demo/HippyDemo/ViewController.m b/examples/ios-demo/HippyDemo/ViewController.m index d5dbdd408bd..ca55b8eb23b 100644 --- a/examples/ios-demo/HippyDemo/ViewController.m +++ b/examples/ios-demo/HippyDemo/ViewController.m @@ -40,13 +40,45 @@ @interface ViewController () logLevelMap.count ? logLevelMap[1] : logLevelMap[level]; + + if(fileName){ + return [[NSString alloc] initWithFormat:@"[%@][%@:%d][%@]%@", + [formatter stringFromDate:timestamp], + fileName.lastPathComponent, + lineNumber.intValue, + levelStr, + message + ]; + }else{ + return [[NSString alloc] initWithFormat:@"[%@]%@", + [formatter stringFromDate:timestamp], + message + ]; + } +} + @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; HippySetLogFunction(^(HippyLogLevel level, HippyLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { - NSLog(@"hippy says:%@ in file [%@:%d]", message, fileName, lineNumber.intValue); + NSString *log = formatLog([NSDate date], level, fileName, lineNumber, message); + if([log hasSuffix:@"\n"]){ + fprintf(stderr, "%s", log.UTF8String); + }else{ + fprintf(stderr, "%s\n", log.UTF8String); + } });