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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions React/Base/RCTLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ typedef void (^RCTLogFunction)(
* particular data from the log, just pass nil or zero for the argument.
*/
RCT_EXTERN NSString *RCTFormatLog(
NSDate *timestamp,
RCTLogLevel level,
NSString *fileName,
NSNumber *lineNumber,
NSString *message
Expand Down
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