Skip to content

Commit

Permalink
Update RCTLog.mm
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyBurger authored Jun 24, 2019
1 parent 08bfdfa commit 08af9c3
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions React/Base/RCTLog.mm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void RCTSetLogThreshold(RCTLogLevel threshold) {
NSString *message
)
{
NSString *log = RCTFormatLog([NSDate date], level, fileName, lineNumber, message);
NSString *log = RCTFormatLog(fileName, lineNumber, message);
fprintf(stderr, "%s\n", log.UTF8String);
fflush(stderr);

Expand Down Expand Up @@ -145,28 +145,16 @@ void RCTPerformBlockWithLogPrefix(void (^block)(void), NSString *prefix)
}

NSString *RCTFormatLog(
NSDate *timestamp,
RCTLogLevel level,
NSString *fileName,
NSNumber *lineNumber,
NSString *message
)
{
NSMutableString *log = [NSMutableString new];
if (timestamp) {
static NSDateFormatter *formatter;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
formatter = [NSDateFormatter new];
formatter.dateFormat = formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss.SSS ";
});
[log appendString:[formatter stringFromDate:timestamp]];
}
if (level) {
[log appendFormat:@"[%s]", RCTLogLevels[level]];
}

[log appendFormat:@"[tid:%@]", RCTCurrentThreadName()];
if ([RCTCurrentThreadName() isEqualToString:@"com.facebook.react.JavaScript"]) {
[log appendFormat:@"[JS]"];
}

if (fileName) {
fileName = fileName.lastPathComponent;
Expand Down

0 comments on commit 08af9c3

Please sign in to comment.