Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Make logs shorter #25383

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update RCTLog.mm
  • Loading branch information
JonnyBurger committed Jun 24, 2019
commit 08af9c3f4dcb7b641cc1d4ef8bb09da958ce1e1b
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